Year 7 · Y7.3 Introduction to Python · Lesson 1

Stretch tasks Output and variables

Task 1

Quiz Challenge

A quiz game against four computer players, then short and long written answers.

  1. Quiz Blitz12 questions against the clock
  2. Quick Fire4 short answers
  3. Big Think2 long answers

About 20 minutes

Task 2

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

Task 3

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

  1. What is printed?

    print("Hello, world!")
    • "Hello, world!"
    • print Hello, world!
    • Nothing
    • Hello, world!
  2. Which line prints the number 42, rather than the text 42?

    • print('42')
    • print(42)
    • print("42")
    • print("forty-two")
  3. What is printed?

    score = 0
    score = score + 10
    score = score + 5
    print(score)
    • 10
    • 5
    • 0
    • 15
  4. In Python, score = 10 means score is equal to 10, just like in maths.

    • True
    • False
  5. Which of these is a valid variable name?

    • first name
    • 1st_name
    • first-name
    • first_name
  6. Score and score are the same variable.

    • True
    • False
  7. What is printed?

    name = "Aisha"
    print("name")
    • Aisha
    • "Aisha"
    • An error
    • name
  8. Which TWO are good variable names for a player's score?

    Tick 2.

    • player_score
    • x
    • s1
    • thing
    • score
  9. Put these lines in order so that the program prints 12.

    Number these 1 to 3.

    • print(age)
    • age = 11
    • age = age + 1
  10. What is printed?

    x = 5
    x = x * 2
    print(x)

  11. 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
  12. 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

  1. What does the = sign do in age = 12? [2 marks]

  2. Explain what score = score + 10 does. [2 marks]

  3. Give two rules for naming variables in Python. [2 marks]

  4. Explain the difference between print(42) and print("42"). [2 marks]

Quiz Challenge, round 3: Big Think

  1. Explain how this program works and what it prints. [4 marks]

    score = 0
    score = score + 10
    score = score + 5
    print(score)

  2. 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

  1. What is printed?

    name = "Sam"
    print(name)
    • Sam
    • name
  2. Which line stores 12 in a variable called age?

    • 12 = age
    • age = 12
  3. Do numbers need quotation marks inside print?

    • No
    • Yes
  4. Are Score and score the same variable?

    • Yes: capitals do not matter
    • No: Python is case sensitive
  5. What is printed?

    x = 3
    x = x + 4
    print(x)
    • 7
    • 3
  6. Which variable name is allowed?

    • first name
    • first_name
  7. What does = mean in score = 0?

    • Check whether score is 0
    • Put 0 into score
  8. Which is the better name for a variable holding a height in metres?

    • h1
    • height

Memory Match: match each term to its meaning

TermMeaning
A Variable1 Adds 10 to score
B print()2 Puts a value into a variable
C =3 A named box that stores a value
D Quotation marks4 Score and score are different
E Case sensitive5 Turn a value into text
F score = score + 106 Shows something on the screen
Answers

Round 1: Quiz Blitz

  1. Hello, world! print shows the text inside the quotation marks, without the marks themselves.
  2. print(42) Numbers do not need quotation marks. Anything inside quotes is text.
  3. 15 score becomes 10, then 15.
  4. False = means put this value into this box. It stores a value; it does not say two things are equal.
  5. first_name A name starts with a letter and has no spaces. A hyphen would be read as a minus sign.
  6. False Python is case sensitive, so they are two different variables.
  7. name The quotation marks make it the text name, not the variable. Without them it would print Aisha.
  8. score; player_score Choose names that say what they hold.
  9. age = 11 → age = age + 1 → print(age) Create the variable, change it, then print it.
  10. 10 x * 2 is 10, and that answer is put back into x.
  11. Stores 1.52 in a variable called height = stores the value on the right in the box named on the left.
  12. 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 answer

    It 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 answer

    It 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 answer

    A 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 answer

    print(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 answer

    score 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 answer

    Python 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

  1. Sam Without quotation marks, name is the variable, so its value Sam is printed.
  2. age = 12 The variable's name goes on the left of =, and the value on the right.
  3. No print(42) works. Quotation marks would turn the number into text.
  4. No: Python is case sensitive Python treats them as two different variables.
  5. 7 x + 4 is 7, which is put back into x.
  6. first_name Variable names cannot contain spaces. Use an underscore instead.
  7. Put 0 into score One = stores a value. Checking whether two values are equal uses ==.
  8. height Choose 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