Python lesson 2

Python programming 
Lesson 2
1 / 23
suivant
Slide 1: Diapositive
ComputingLower Secondary (Key Stage 3)

Cette leçon contient 23 diapositives, avec quiz interactifs et diapositives de texte.

time-iconLa durée de la leçon est: 50 min

Éléments de cette leçon

Python programming 
Lesson 2

Slide 1 - Diapositive

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

Slide 2 - Question ouverte

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

Aspire: Create your own variables. 

Slide 3 - Diapositive

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

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

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

Slide 6 - Diapositive

What will this code do?

Make your prediction

Slide 7 - Question ouverte

Lets check your prediction 
Run the code

Click the green play button

Slide 8 - Diapositive

Run the following code:

What has changed about this code?

Slide 9 - Question ouverte

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

Variables
We use variables to save information inside our programs.

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

Slide 11 - Diapositive

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

Create 5 variables
To store
Click here
Your name
Favorite food 
Dream holiday destination
Age
Favorite Film

Slide 13 - Diapositive

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

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

Slide 16 - Quiz

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

Slide 17 - Quiz

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

Slide 18 - 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 19 - Diapositive

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 20 - Diapositive

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 21 - Question de remorquage


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

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

Slide 23 - Diapositive