Python lesson 2

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

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

time-iconLesson duration is: 50 min

Items in this lesson

Python programming 
Lesson 2

Slide 1 - Slide

What are the errors in this program?
Extension: What will the outcome of this program be when fixed?
Click Here

Slide 2 - Open question

KEY OBJECTIVE
Conquer: To understand the need for variables and inputs. 

Aspire: Create your own variables. 

Slide 3 - Slide

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


Slide 4 - Slide

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

Task 1 - PREDICT
What do you think this code will do?

Slide 6 - Slide

What will this code do?

Make your prediction

Slide 7 - Open question

Lets check your prediction 
Run the code

Click the green play button

Slide 8 - Slide

Run the following code:

What has changed about this code?

Slide 9 - Open question

INVESTIGATE and MODIFY
  • Make the program call the other two functions
  • Change the name in the printing2 procedure to your name

  • (Harder) Add more text after the greeting in printing3 so it will print the following --> "Hello Sally , nice to meet you"
  • CLICK ME

Slide 10 - Slide

Variables
We use variables to save information inside our programs.

This information could be your name, score, health and more.

Slide 11 - Slide

Creating variables
To create a variable we need to give it a name




We then store the information we want inside with the = Sign

Slide 12 - Slide

Create 5 variables
To store
Click here
Your name
Favorite food 
Dream holiday destination
Age
1 GCSE option choice

Slide 13 - Slide

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

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

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

Slide 16 - Quiz

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

Slide 17 - Quiz

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

Slide 18 - Quiz

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

Slide 19 - Quiz

Inputs
Sometimes we want the user to be able to enter their own information to store



We make the variable in the same way, but this time we add the word input to allow the user to respond

Slide 20 - Slide

Lesson task
Create 4 variables with inputs that asks the following questions
What is your full name?
What was your favorite thing about the holidays? 
What are you looking forward to for your options?
What can you improve on from last year? 


Slide 21 - Slide

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


Which of these variable names would be most suitable to hold data on a person's surname in Python?
A
lastName
B
firstName
C
surname
D
Age

Slide 23 - Quiz

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

Slide 24 - Slide