Python Development Lesson 1

Python Development Lesson 1
1 / 28
volgende
Slide 1: Tekstslide
LessonUpLower Secondary (Key Stage 3)

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

time-iconLesduur is: 60 min

Onderdelen in deze les

Python Development Lesson 1

Slide 1 - Tekstslide

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

Slide 2 - Quizvraag

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

Slide 3 - Quizvraag

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

Slide 4 - Quizvraag

Overview
In HT3 you designed a text based adventure game
This half term we are making it!

(optional) First task - Locate your designed games (slides etc) and have 5 minutes to remind yourself of your design

Slide 5 - Tekstslide

Outputs
A message outputted to the user (like on screen).

Here are some examples in Python
print ("Dave")                - the word Dave would be output
print(6)                            - the number 6 would be output
print(name)                   - the value stored in the variable would be output
print(7*3)                       - would print out 21 as it performs the sum first

Point out that text needs quotes and number do not need them

Slide 6 - Tekstslide

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 7 - Tekstslide

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 8 - Tekstslide

Python Refresh STAGE 1
The simplest skill to refresh is outputs and varibles
in python this is printing.
CLICK HERE to see the example

CLICK HERE to try a challenge

DO extra demos where necessary

Slide 9 - Tekstslide

What is a variable?

Slide 10 - Open vraag

You have written a program that stores a name in a variable and prints a greeting using that variable. Which is correct code for this
A
Print(Hello,"name")
B
print(Hello,"name")
C
print("Hello",name)
D
print("hello","name")

Slide 11 - Quizvraag

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

Python Refresh STAGE 2
Now we will refresh the conditional (selections) in coding
This is the use of IF/ELIF and ELSE

CLICK HERE to see some examples

CLICK HERE to try some challenges

Slide 13 - Tekstslide

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

Slide 14 - Quizvraag

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

Slide 15 - Quizvraag

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

Slide 16 - Quizvraag

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

Slide 17 - 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 18 - Quizvraag

CheckPoint
You should be happy with the following terms and how to code them in Python:
  • printing outputs
  • setting variables (with or without and input from user)
  • using If, elif and else properly 
  • can explain the difference in using if, elif and else
  • IF YOU DO NOT understand these then tell your teacher

Slide 19 - 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 20 - Tekstslide

While loops
While loops will repeat until a condition is met
CLICK THIS to see some examples

CLICK THIS for a challenge use while loops

Slide 21 - Tekstslide

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

Slide 22 - Quizvraag

Which symbol will check is two values DO NOT equal each other
A
!=
B
NOT=
C
¬=
D
=/=

Slide 23 - 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 24 - Quizvraag

For loops
For loops repeat code a set amount of times and are not waiting on a condition to be met.
CLICK THIS to see some examples and tweak it where asked.

Slide 25 - Tekstslide

What is the output of this for loop in python:
for i in range(3):
print(i)
A
0 1 2
B
0 1 2 3
C
3
D
iii

Slide 26 - Quizvraag

When should you use a for loop instead of a while loop?
A
When the loop has to run indefinitely
B
When the loop involves complex logic
C
when we need a variable
D
When you know the number of iterations

Slide 27 - Quizvraag

Link Summary
CLICK HERE - Input/output recap
CLICK HERE - Input/output tasks
CLICK HERE - IF/ELIF/ELSE recap
CLICK HERE - IF/ELIF/ELSE tasks
CLICK HERE - While loop recap
CLICK HERE - While loop tasks
CLICK HERE - For loop recap and task



Slide 28 - Tekstslide