Y8 Python

Python
On the road to code!
1 / 30
next
Slide 1: Slide
ComputingLower Secondary (Key Stage 3)

This lesson contains 30 slides, with interactive quizzes and text slides.

Items in this lesson

Python
On the road to code!

Slide 1 - Slide

What is Python?

Slide 2 - Mind map

Python
  • High level programming language
  • Allows you to create your own programs
  • Text based

Slide 3 - Slide

Recall
Try these old recall questions on things you should know about programming

Slide 4 - Slide

Code that runs one line after another is known as coding in...
A
Sequence
B
Selection
C
Iteration
D
Recursion

Slide 5 - Quiz

Code that repeats/loops is known as coding in...
A
Sequence
B
Selection
C
Iteration
D
Recursion

Slide 6 - Quiz

Code that only runs when a condition is met is known as coding in...
A
Sequence
B
Selection
C
Iteration
D
Recursion

Slide 7 - Quiz

An example of a loop in python would be:
A
print("this")
B
while x > 0 :
C
if x == 0 :
D
name = input("-->")

Slide 8 - Quiz

A value that is used by the program and can change is known as a...
A
constant
B
procedure
C
function
D
variable

Slide 9 - Quiz

Refresh
Time to refresh those skills

Slide 10 - Slide

outputs
Used to output messages to the screen
In Python we use print
print ("hello world")

Slide 11 - Slide

Slide 12 - Link

Variables
An area in memory used to store a value the program will use.
The value is likely to change
Here are some examples in Python
name = "Dave"                      - Text 
health = 100                           - Integer
discount = False                  - Boolean  (True/False)

Slide 13 - Slide

Inputs
We often use variables to store inputs from the user
In Python we use input
input ("Question the user will see as a prompt")
So to store a name we would use:
name = input ("What is your name  ? -->  ")

Slide 14 - Slide

Checkpoint
Label the correct parts of this code (drag them)

filmpref = input("What kind of films do you like? ")

Variable
This is aplaceholder for a value that will change in the program
function
This is a calling a pre-made function from the python library
All functions are followed by brackets ()
Sometimes information is written between these brackets
This is called a "parameter"
Parameter
This is a text prompt which is the parameter of the input function.
It will pop up on screen before taking an input from the user

Slide 15 - Slide

Slide 16 - Link

CORRECT
CAUSE AN ERROR
print = ("Hello")
Print("Yes!")
print("this one)
name = imput("what is your name")
name = input("what is your name")
print("this text")
fav colour = "Green"
age = 10
print("Hello", name)
print("Bye",name")

Slide 17 - Drag question

IF/ELIF/ELSE
When we need to make a decision in a program we use a selection statement .
In Python we use if  elif  and  else

Let's look at some coded examples...

Slide 18 - Slide

Slide 19 - Link

Now Try Yourself

Slide 20 - Slide

Slide 21 - Link

In python you must write IF, ELIF and ELSE in capital letters
A
TRUE
B
FALSE

Slide 22 - Quiz

After every if, elif and else statement you put ...
A
;
B
}
C
:
D
#

Slide 23 - Quiz

An elif part of the code will only run if the if part was not met
A
True
B
False

Slide 24 - Quiz

an if statement must always have an else component
A
True
B
False

Slide 25 - Quiz

which of the following if statements would cause an error
A
if name != "Fred":
B
if password == guess:
C
if name = "Bobby":
D
if age >= 18 :

Slide 26 - Quiz

While Loops
Sometimes you need the computer to repeat steps until a certain condition has been met
In Python we use while  and  for

Let's look at some coded examples of a while loop...

Slide 27 - Slide

Slide 28 - Link

Your Turn
Making a quiz question program

Slide 29 - Slide

Slide 30 - Link