Download presentation
Presentation is loading. Please wait.
Published byMitchell Craig Modified over 9 years ago
1
Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
A Simple Calculator Guess the Number Fantastic Functions Secret Messages Adventure Game Python Magic
2
Why should we learn to program?
YouTube video to go here.
3
Basic Python Syntax
4
Understand and be able to use basic Python syntax.
5
VARIABLES The way we store data. String – a type of variable for storing text “strings”.
6
Enter the code shown here to create your first computer program.
7
Now let’s add to that . . .
8
What do you think this will do?
9
YOUR TASK Add to your program so you can have a conversation with the computer (stick to yes and no answers for now!)
10
Create an account at www.codecademy.com
NEXT TASK Create an account at Complete the first Python course called ‘Python Syntax’
11
Understand and be able to use basic Python syntax.
or
12
Calculator
13
Understand how to use selection to create a simple calculator.
14
VARIABLES String – remember this from last lesson? Numbers: Integer Float
15
What’s happening here ?
16
How we choose a suitable action based on a condition.
SELECTION How we choose a suitable action based on a condition. IF I’m hungry Eat Something ELSE Don’t eat anything
17
Can you add more selection to handle multiplication and division ?
18
Log onto www.codecademy.com
NEXT TASK Log onto and continue the Python course from where you finished last lesson.
19
Understand how to use selection to create a simple calculator.
20
Loopy Loops
21
Understand how to create a loop in Python and use a Boolean variable to define when to stop.
22
ANOTHER VARIABLE Boolean – This can store one of two values: True
False
23
LOOPS A While loop can keep looping through events until a condition changes. WHILE hungry == True Keep eating IF I’m full up hungry == False
24
Have a go at this ‘Guess the Number’ game. What does each part do?
25
Understand how to create a loop in Python and use a Boolean variable to define when to stop.
or
26
Fantastic Functions
27
Understand how to use and call functions.
28
WHAT IS A FUNCTION? A block of code grouped together that can be run at any point in our program.
29
Try creating this function to pull a rabbit from a hat
Try creating this function to pull a rabbit from a hat! Don’t forget the magic word though!
30
Try out this function. What does that bit in brackets do?
31
YOUR CHALLENGE Add to your program so it tells the user whether or not their word is a palindrome. Hint: try using an if statement to compare the original word with the reversed word.
32
You should have added something like this to the end of your program.
33
Log onto www.codecademy.com
NEXT TASK Log onto and continue the Python course from where you finished last lesson.
34
Secret Messages
35
Understand how to store and look up values from a list.
36
(Also known as an array)
LIST (Also known as an array) A way of storing more than one thing under one variable name. My magic potion contains hair, knotgrass and leeches.
37
Here’s a list of students. What will each print statement do?
38
Another way to add items is using the ‘append’ command
Another way to add items is using the ‘append’ command. Use this to add some more students. Make sure you print your list of students again to make sure your code has worked!
39
For example, a shift of 2 means “A” becomes “C”:
CAESAR SHIFT A well-known cipher to encode a piece of text by replacing one letter of the alphabet with another a chosen number of places (shifts). For example, a shift of 2 means “A” becomes “C”: A B C D E F G H I K L. . .
40
Cut out and make your own Caesar Cipher Wheel using your worksheet.
TASK Cut out and make your own Caesar Cipher Wheel using your worksheet. Use your wheel to create a secret message for the person next to you to decode.
41
Can you decode this secret message?
s vyfo mywzedob zbyqbkwwsxq Are there any clues to help us work out the shift number? Clue – how many words have only one letter? This should narrow down the choices.
42
Create your own encryption program and test it out.
What is happening here? Create your own encryption program and test it out. EXTENSION – new program to decode a secret message.
43
Text Adventures
44
Recognise how a class can be used to create custom objects.
45
A custom object that you can make that has it’s own set of attributes.
CLASSES A custom object that you can make that has it’s own set of attributes.
46
Animal Class Giraffe Horse Lion
47
Open and look at the Animals.py example from SharePoint.
TASK Open and look at the Animals.py example from SharePoint. Can you figure out what some of the bits of code are doing?
48
Underneath the class create a new ‘instance’ of an animal and give it some attributes. You can choose any animal you like.
50
TASK Use the design sheet to plan your own text adventure then follow the instructions to create this in Python.
51
Recognise how a class can be used to create custom objects.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.