Python lesson 4

Python lesson 4
1 / 18
volgende
Slide 1: Tekstslide
ComputingLower Secondary (Key Stage 3)

In deze les zitten 18 slides, met interactieve quizzen en tekstslides.

time-iconLesduur is: 50 min

Onderdelen in deze les

Python lesson 4

Slide 1 - Tekstslide

Do Now: Fix the code, paste your fixed code below

Extension:

Slide 2 - Open vraag

Lesson 4: Python programming
Conquer: Define the term iteration

Aspire: Use iteration in a program to form a loop. 


Slide 3 - Tekstslide

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 4 - Sleepvraag

Slide 5 - Tekstslide

Label the correct parts of this code (drag them - text at the bottom)to create an if statement that checks if the value is  greater than 20
Incorrect code
Checkpoint

Slide 6 - Sleepvraag

Label the correct parts of this code (drag them - text at the bottom)to create an if statement that checks if the number is less than 100
Incorrect code
Checkpoint

Slide 7 - Sleepvraag

If statement practice
Create a a program that will ask the user their favorite subject.

  1. if enterprise is chosen say correct enterprise is the best
  2. If PE is chosen, say we cant do that its raining 
  3. if anything else is entered, say unfortunately you didn't say enterprise. 
  4. Click here to code

Slide 8 - Tekstslide

Looping code
  • Sometimes you need the computer to repeat steps until something happens (a condition being met)

  • In Python we can use either while or for loops

  • Lets look at each in turn

Slide 9 - Tekstslide

While loops will repeat until a condition is met

Slide 10 - Tekstslide

Loop task: ISL
Create 2 while loops in a program
  • 1 loop will count to 100
  • 1 loop will count down from 100 



Slide 11 - Tekstslide

ISL Extension
1. Write a While loop that adds together all the numbers from 1 to 100.

2. Write a While loop that will repeat a question until the user gets the answer correct.  Hint - you will need to use an 'input' and an 'if'

3. Change your code from question 2, so they only get 5 attempts to answer


Slide 12 - Tekstslide

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

Slide 13 - Quizvraag

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

Slide 14 - Quizvraag

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

Slide 15 - Quizvraag

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 16 - Quizvraag

Which symbol will check is two values are the same in a while condition?
A
!=
B
==
C
=
D
"="

Slide 17 - Quizvraag

What would this code do when run:
x=1
while x != 10:
print(x)
A
Count to 10 on screen
B
Count to 9 on screen
C
print the value 1 over and over forever
D
produce a syntax error

Slide 18 - Quizvraag