Python lesson 2

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

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

time-iconLesduur is: 50 min

Onderdelen in deze les

Python programming 
Lesson 2

Slide 1 - Tekstslide

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

Slide 2 - Open vraag

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

Aspire: Create your own variables. 

Slide 3 - Tekstslide

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

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

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

Slide 6 - Tekstslide

What will this code do?

Make your prediction

Slide 7 - Open vraag

Lets check your prediction 
Run the code

Click the green play button

Slide 8 - Tekstslide

Run the following code:

What has changed about this code?

Slide 9 - Open vraag

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

Variables
We use variables to save information inside our programs.

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

Slide 11 - Tekstslide

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

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

Slide 13 - Tekstslide

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

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

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

Slide 16 - Quizvraag

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

Slide 17 - Quizvraag

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

Slide 18 - Quizvraag

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

Slide 19 - Quizvraag

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

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

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


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

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

Slide 24 - Tekstslide