Python Development Lesson 1 - JM Lesson Obs

Python Development Lesson 1
1 / 35
next
Slide 1: Slide
LessonUpLower Secondary (Key Stage 3)

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

time-iconLesson duration is: 60 min

Items in this lesson

Python Development Lesson 1

Slide 1 - Slide

What is programming?

Slide 2 - Open question

What is Syntax?

Slide 3 - Open question

Common 'Syntax' Errors
The most common Syntax errors are:

  • missing a comma, colon, quotation mark, or misspelling a word.

Slide 4 - Slide

KO: To be-able to debug and fix errors in code.
All
  •  To use the 'Syntax' of Python to identify errors in a line of code.

Most
  • To explain what a 'Variable' is and how they are used in coding.
  • To explain what a 'Selection' statement is and how they are used in coding.


Some 
  • To demonstrate and use a 'Variable' in some code.
  • To demonstrate and use a 'Selection' statement in some code.

Slide 5 - Slide

Code that runs one line after another 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

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

Slide 8 - Quiz

print statement
Think back to Year 7 and Year 8.

Can you remember how to create a print statement in Python?

If you're not sure, discuss with the person next to you...

Click here to code.

Slide 9 - Slide

What is an output?
A message outputted to the user (like on screen).

Here are some examples of different outputs 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 10 - Slide

What is a Variable?
An area in memory used to store a value the program will use.

The value can change.
Here are some examples of Variables in Python
name = "Dave"                      - Text 
health = 100                           - Integer
discount = False                  - Boolean  (True/False)

Slide 11 - Slide

Inputs
We can 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 12 - Slide

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

CLICK HERE to try a challenge

DO extra demos where necessary

Slide 13 - Slide

Challenge
Using what we have learnt so far in pairs, I want you to create a sentence, using 2 variables. You must ask the user for their input.

Slide 14 - Slide

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 15 - Quiz

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 16 - Drag question

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

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

Slide 18 - Quiz

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

Slide 19 - Quiz

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

Slide 20 - Quiz

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

Slide 21 - 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 22 - Quiz

In your own words: What is a 'Selection' statement?

Slide 23 - Open question

Plenary 
To show me your understanding, I want you to create a short program. Click here

  You must:
  • Ask the user for their input.
  • Use selection statements with if, elif and else.
  • You must use print statements.

Slide 24 - Slide

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 25 - Slide

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 26 - Slide

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 27 - Slide

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

Slide 28 - Quiz

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

Slide 29 - Quiz

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 30 - Quiz

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 31 - Slide

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 32 - Quiz

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 33 - Quiz

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 34 - Slide

What is a variable?

Slide 35 - Open question