Python lesson 3

Python programming 
Lesson 3
1 / 20
next
Slide 1: Slide
ComputingLower Secondary (Key Stage 3)

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

time-iconLesson duration is: 50 min

Items in this lesson

Python programming 
Lesson 3

Slide 1 - Slide

This item has no instructions

Add a question for the user asking them how their day is. Allow for 2 response options.
Extention: Add optional responses with different spelling/caps
Click Here

Slide 2 - Open question

This item has no instructions

KEY OBJECTIVE
Conquer: To understand the need for conditional statements

Aspire: Create your own conditional statements. 

Slide 3 - Slide

This item has no instructions

Previously you have:

Written a program in a sequence
Used the print statement
Used a subroutine
Checked for errors in your code
Fixed common errors in your code
Added inputs to allow the user to respond/

Slide 4 - Slide

This item has no instructions

PRIMM
All new programmers use the PRIMM method to learn and create new code. There are 5 key stages. 
  1. Predict
  2. Run
  3. Investigate
  4. Modify
  5. Make

Slide 5 - Slide

This item has no instructions

Task 1 - PREDICT
Adding conditions

We have been taking inputs, storing variables and outputting results to the screen

Now we need to add some conditions.

Slide 6 - Slide

This item has no instructions

What will happen in this program if I enter "sunny" and then "raining"?

Slide 7 - Open question

10 is more than 5

Statement is true

Output 10+5 = 15
Lets check your prediction 
Run the code

Click the green play button

Slide 8 - Slide

This item has no instructions

INVESTIGATE and MODIFY
  • Add another question
  • Ask the user how they are feeling
  • If the user enters happy give a positive message.
  • If they enter unhappy give a hopeful message. 


Slide 9 - Slide

This item has no instructions

Conditional statements
If statements allow the program to give different responses to user inputs. 



Slide 10 - Slide

This item has no instructions

Operators 
  1. == (Equal to)
  2. != (Not equal to)
  3. > (Greater than)
  4. < (Less than)
  5. >= (Greater than or equal)
  6. < (Less than or equal)

Slide 11 - Slide

This item has no instructions

Creating a calculator 
Sorting inputs

Slide 12 - Slide

This item has no instructions

Predict:


What will the outcome of this code be?
A
Hello world will appear
B
"Hello world" will appear
C
Nothing
D
An error will occur

Slide 13 - Quiz

This item has no instructions

Predict:

What will the outcome of this code be?
A
Error on line 4
B
Error on line 7
C
Hello there
D
Nothing

Slide 14 - Quiz

This item has no instructions

Which code below will call a function?
A
def menu()
B
Hello world
C
menu()
D
score = 0

Slide 15 - Quiz

This item has no instructions

What is the process of fixing errors in your program?
A
Error checking
B
Debugging
C
Syntax errors
D
Python

Slide 16 - Quiz

This item has no instructions

What is the name of the format we have to write in python
A
Grammar
B
Debugging
C
Syntax
D
Functions

Slide 17 - Quiz

This item has no instructions

What keyword do we use to create a function?
A
def
B
Define
C
def()
D
Define function.

Slide 18 - Quiz

This item has no instructions

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

This item has no instructions

Mastery typing task
To become efficient programmers we must get better and faster at typing

Slide 20 - Slide

This item has no instructions