Scratch variable blocks as Python assignment

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Scratch variable blocks as Python assignment

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which Python line matches the Scratch block 'set score to 0'?
A score = 0
B score + 0
2. Which Python line matches the Scratch block 'change score by 1'?
A score = score + 1
B score = 1
3. score is 5. What is score after score = score + 1 runs?
A 6
B 5
4. Which Python line matches the Scratch block 'change score by -1'?
A score = -1
B score = score - 1
5. In score = score + 1, which side does Python work out first?
A The left side (score)
B The right side (score + 1)

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1score = 0 AThis works out an answer but never stores it. Without score = at the start, score does not change, so it does not match 'change score by 1'.
2score = score + 1 BDoes the same job as the Scratch block 'change score by 1'. Python works out score + 1 first, then stores the answer back in score.
3The Scratch block 'change score by -1' takes one point away from score. Cscore = score + 1
4Python works out the right side of an assignment first, using the old value of score, and then saves the answer in score. DA double equals sign compares values and asks a question. It does not set score. Use a single equals sign to match 'set score to 0'.
5score + 1 EDoes the same job as the Scratch block 'set score to 0'. It puts the starting value 0 into the variable score.
6score == 0 Fscore = score - 1

Definitions

score = score + 1

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
score = _
2.
score = _____ + 1
3.
score = score _ 1
4.
score = 0 score _ score + 1
5.
# change score by 5 score = score + _

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A score = 0
B score = score + 1
C score + 1 = score
D print(score)
Question 2
A score == 0
B score = score + 1
C print(score)
Question 3
A lives = 3
B lives = live - 1
C print(lives)
Question 4
A score = 0
B score = Score + 1
C print(score)
Question 5
A score = 10
B score = score + 5
C score - 1
D print(score)

Answer Key

Scratch variable blocks as Python assignment
Section A: Quick Questions
Q1
A — score = 0
Q2
A — score = score + 1
Q3
A — 6
Q4
B — score = score - 1
Q5
B — The right side (score + 1)
Section B: Match the Pairs
Q1
score = 0 → Does the same job as the Scratch block 'set score to 0'. It puts the starting value 0 into the variable score.
Q2
score = score + 1 → Does the same job as the Scratch block 'change score by 1'. Python works out score + 1 first, then stores the answer back in score.
Q3
The Scratch block 'change score by -1' takes one point away from score. → score = score - 1
Q4
Python works out the right side of an assignment first, using the old value of score, and then saves the answer in score. → score = score + 1
Q5
score + 1 → This works out an answer but never stores it. Without score = at the start, score does not change, so it does not match 'change score by 1'.
Q6
score == 0 → A double equals sign compares values and asks a question. It does not set score. Use a single equals sign to match 'set score to 0'.
Section C: Definitions
Q1
score = score + 1 — Python for the Scratch block 'change score by 1'. Python works out the right side first, then stores the answer back in score. Use score = 0 to set it.
Section D: Fill in the Blanks
Q1
score = 0
Q2
score = score + 1
Q3
score = score - 1
Q4
score = 0 score = score + 1
Q5
# change score by 5 score = score + 5
Section E: Spot the Error
Q1
C — The variable being changed must be on the left of the = sign. Python works out the right side first and stores it in the left. It should be score = score + 1.
Q2
A — == compares two values. It does not set the variable, so score never exists. To set score to 0 (like the Scratch 'set score to 0' block), use a single =: score = 0.
Q3
B — The variable name is spelled wrongly. Python does not know 'live', so it gives a NameError. The Scratch block 'change lives by -1' is lives = lives - 1.
Q4
B — Python is case-sensitive, so Score is a different name from score and does not exist. It should be score = score + 1.
Q5
C — This works out score - 1 but never stores the answer anywhere, so score stays the same. To match 'change score by -1', write score = score - 1.