Year 7 · Y7.3 Introduction to Python · Lesson 1
Stretch tasks Output and variables
Quiz Challenge
A quiz game against four computer players, then short and long written answers.
- Quiz Blitz12 questions against the clock
- Quick Fire4 short answers
- Big Think2 long answers
About 20 minutes
This or That
Pixel the cat asks 8 questions. Each has two answers: pick the right one.
- Two answers to every question
- A fish treat for every right answer
- Streaks win Pixel shades, then a party hat
About 4 minutes
Memory Match
Flip the cards two at a time to match each term card to its meaning card.
- 12 cards: each term has a meaning
- One peek at every card
- Combo points for pairs found in a row
6 pairs, about 4 minutes
The games need JavaScript. Every question is below, with the answers at the end.
Read the lesson: Output and variables
Output and variables: the questions
Quiz Challenge, round 1: Quiz Blitz
What is printed?
print("Hello, world!")- "Hello, world!"
- print Hello, world!
- Nothing
- Hello, world!
Which line prints the number 42, rather than the text 42?
print('42')print(42)print("42")print("forty-two")
What is printed?
score = 0 score = score + 10 score = score + 5 print(score)- 10
- 5
- 0
- 15
In Python, score = 10 means score is equal to 10, just like in maths.
- True
- False
Which of these is a valid variable name?
- first name
- 1st_name
- first-name
- first_name
Score and score are the same variable.
- True
- False
What is printed?
name = "Aisha" print("name")- Aisha
- "Aisha"
- An error
- name
Which TWO are good variable names for a player's score?
Tick 2.
- player_score
- x
- s1
- thing
- score
Put these lines in order so that the program prints 12.
Number these 1 to 3.
print(age)age = 11age = age + 1
What is printed?
x = 5 x = x * 2 print(x)What does the line height = 1.52 do?
- Prints 1.52
- Checks whether height equals 1.52
- Causes an error
- Stores 1.52 in a variable called height
Why does text need quotation marks?
- To make it bold
- To make it print faster
- So Python can count the letters
- So Python knows it is text, not a variable name
Quiz Challenge, round 2: Quick Fire
What does the = sign do in age = 12? [2 marks]
Explain what score = score + 10 does. [2 marks]
Give two rules for naming variables in Python. [2 marks]
Explain the difference between print(42) and print("42"). [2 marks]
Quiz Challenge, round 3: Big Think
Explain how this program works and what it prints. [4 marks]
score = 0 score = score + 10 score = score + 5 print(score)A student writes Score = 0 and later print(score), and gets an error. Explain why, and give three rules for good variable names. [6 marks]
This or That: tick the right answer
What is printed?
name = "Sam" print(name)- Sam
- name
Which line stores 12 in a variable called age?
12 = ageage = 12
Do numbers need quotation marks inside print?
- No
- Yes
Are Score and score the same variable?
- Yes: capitals do not matter
- No: Python is case sensitive
What is printed?
x = 3 x = x + 4 print(x)- 7
- 3
Which variable name is allowed?
first namefirst_name
What does = mean in score = 0?
- Check whether score is 0
- Put 0 into score
Which is the better name for a variable holding a height in metres?
h1height
Memory Match: match each term to its meaning
| Term | Meaning |
|---|---|
| A Variable | 1 Adds 10 to score |
B print() | 2 Puts a value into a variable |
C = | 3 A named box that stores a value |
| D Quotation marks | 4 Score and score are different |
| E Case sensitive | 5 Turn a value into text |
F score = score + 10 | 6 Shows something on the screen |
Answers
Round 1: Quiz Blitz
- Hello, world! print shows the text inside the quotation marks, without the marks themselves.
print(42)Numbers do not need quotation marks. Anything inside quotes is text.- 15 score becomes 10, then 15.
- False = means put this value into this box. It stores a value; it does not say two things are equal.
- first_name A name starts with a letter and has no spaces. A hyphen would be read as a minus sign.
- False Python is case sensitive, so they are two different variables.
- name The quotation marks make it the text name, not the variable. Without them it would print Aisha.
- score; player_score Choose names that say what they hold.
age = 11→age = age + 1→print(age)Create the variable, change it, then print it.- 10 x * 2 is 10, and that answer is put back into x.
- Stores 1.52 in a variable called height = stores the value on the right in the box named on the left.
- So Python knows it is text, not a variable name Without quotes, Python treats a word as a variable name or a command.
Round 2: Quick Fire
- It puts the value into the variable
- It does not mean equal, as it would in maths
Model answerIt puts the value 12 into the variable called age. It does not mean that age is equal to 12, as it would in maths.
- It adds 10 to the value score already holds
- It puts the answer back into score
Model answerIt works out score + 10, adding 10 to the current value, then puts the answer back into score, so score goes up by 10.
- Start with a letter
- No spaces
- Names are case sensitive
- Choose a name that says what it holds
Model answerA variable name must start with a letter and cannot contain spaces.
- 42 without quotation marks is a number
- "42" with quotation marks is text, a string
Model answerprint(42) shows 42 as a number. print("42") shows 42 as text, a string, because of the quotation marks.
Round 3: Big Think
- score starts at 0
- 10 is added, so score becomes 10
- 5 is added, so score becomes 15
- Each line works out the right side and puts it back into score
- It prints 15
Model answerscore starts at 0. The second line adds 10 and puts the answer back into score, so it becomes 10. The third line adds 5, so score becomes 15. The last line prints 15.
- Python is case sensitive
- So Score and score are two different variables
- score was never created, so it does not exist
- Fix it by using exactly the same name everywhere
- Rule: start with a letter
- Rule: no spaces
- Rule: choose a name that says what it holds
Model answerPython is case sensitive, so Score and score are two different variables. The program only created Score, so score does not exist and print(score) gives an error. The fix is to use exactly the same name everywhere. Good variable names start with a letter, have no spaces, and are meaningful, saying what they hold, such as player_score.
This or That
- Sam Without quotation marks, name is the variable, so its value Sam is printed.
age = 12The variable's name goes on the left of =, and the value on the right.- No print(42) works. Quotation marks would turn the number into text.
- No: Python is case sensitive Python treats them as two different variables.
- 7 x + 4 is 7, which is put back into x.
first_nameVariable names cannot contain spaces. Use an underscore instead.- Put 0 into score One = stores a value. Checking whether two values are equal uses ==.
heightChoose names that say what they hold.
Memory Match
- A 3 Variable: A named box that stores a value
- B 6
print(): Shows something on the screen - C 2
=: Puts a value into a variable - D 5 Quotation marks: Turn a value into text
- E 4 Case sensitive: Score and score are different
- F 1
score = score + 10: Adds 10 to score