← ACARA Digital Technologies Years 7–8

Scratch if and if-else blocks as Python if/else

Python's version of Scratch's if block: the hexagon condition becomes a comparison like ==, then a colon, and the blocks inside become indented lines. Add else: for the else part.

Understanding Scratch if and if-else blocks as Python if/else in ACARA Digital Technologies Years 7–8

What it does: The say block inside the if becomes an indented print() line below the if line, so Python knows it belongs to the if. A single = in Python stores a value in a variable, so the Scratch equals check becomes the double equals ==. Python uses indentation, usually 4 spaces, to show which lines are inside the if. It does not use curly brackets. Python needs a colon after else, just like after the if line. The else: lines up with its if, like the bottom 'else' bar of the Scratch block sits at the same level as the 'if' at the top.

Common mistakes: A single = stores a value in a variable. The Scratch = in the hexagon becomes == in Python, so it should be: if score == 10:. A Python if line must end with a colon, which starts the indented block. It should be: if age >= 13:.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 482–519) and word search (Modules 420–519).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A Scratch if block has the hexagon condition (score = 10). Which Python line matches it?
if score == 10:if score = 10:
Matches
if score = 10:
↓
A single = is used for the Scratch equals check, but Python needs == to compare two values. A single = is for assignment.
Applying
Meanings
Term
if score == 10:
Meaning
Python's version of Scratch's if block: the hexagon condition becomes a comparison like ==, then a colon, and the blocks inside become indented lines. Add else: for the else part.
Practice
score = 10
Testing
Gaps
score == 10:
Check Answer
Spots
2print("Checking score")
3if score = 10:

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Puffin' badge — Definition Diver, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A Scratch if block has the hexagon condition (score = 10). Which Python line matches it?
A. if score = 10:
B. if score == 10: ✓
In Python, a single = stores a value in a variable. The Scratch = comparison becomes == in Python.
2. In Scratch, the blocks inside an if block are tucked into the C shape. How does Python show they belong to the if?
A. They are indented lines under the if line ✓
B. They are written in curly brackets { }
Python uses indentation, usually 4 spaces, to show which lines are inside the if. It does not use curly brackets.
3. Which line is the Python version of the 'else' part of a Scratch if-else block?
A. else: ✓
B. else
Python needs a colon after else, just like after the if line.
4. The Scratch hexagon says (age > 12). What does this become in Python?
A. if age > 12: ✓
B. if (age > 12) then
Python has no 'then'. The condition becomes a comparison, and then a colon ends the line.
5. Which Python code is correct for an if-else block that says 'Win!' or 'Try again'?
A. if score == 10: print('Win!') else: print('Try again')
B. if score == 10: print('Win!') else: print('Try again') ✓
The lines inside the if and the else must be indented. Without indentation, Python gives an IndentationError.

Match the Pairs

if score == 10: → The Scratch block 'if score = 10 then' written in Python: the hexagon becomes a comparison, followed by a colon
else: → The 'else' part of a Scratch if-else block, followed by a colon and indented lines for the blocks inside
The blocks inside a Scratch if block become lines indented under the if line → if lives == 0: print("Game over")
The Scratch = in a hexagon checks if two things are equal, so Python uses == in the comparison → if answer == 5:
if score = 10: → A single = is used for the Scratch equals check, but Python needs == to compare two values. A single = is for assignment.
if score == 10 print("Win") → The colon is missing at the end of the if line. Python needs it where the Scratch block opens.

Key Term

if score == 10:
Python's version of Scratch's if block: the hexagon condition becomes a comparison like ==, then a colon, and the blocks inside become indented lines. Add else: for the else part.

Fill in the Blanks

1. if score == 10: print("You win!")
Hint: Type the keyword that replaces the Scratch if block.
2. if score == 10: print("You win!")
Hint: Type the operator that checks if two values are equal, like the = in the Scratch hexagon.
3. if score == 10: print("Win") else:
Hint: Type the keyword for the part that runs when the condition is false.
4. if age >= 13: print("Teen") else:
Hint: Type the comparison operator meaning greater than or equal to.
5. if score == 10: print("You win!") else:
Hint: Type the function that replaces the Scratch say block inside the indented line.

Spot the Error

Question 1
A score = 10
B print("Checking score")
C if score = 10:
D print("Perfect!")
Line C — A single = stores a value in a variable. The Scratch = in the hexagon becomes == in Python, so it should be: if score == 10:
Question 2
A age = 13
B print("Checking age")
C if age >= 13
D print("Teen")
Line C — A Python if line must end with a colon, which starts the indented block. It should be: if age >= 13:
Question 3
A score = 7
B if score == 10:
C print("Win")
D else
E print("Try again")
Line D — The else part of the Scratch if-else block becomes else: in Python. It needs a colon after it, so it should be: else:
Question 4
A lives = 0
B print("Lives left")
C if lives == 0 then:
D print("Game over")
Line C — Scratch blocks say 'then' but Python does not use that word. The condition is followed straight by a colon. It should be: if lives == 0:
Question 5
A answer = input("Ready? ")
B If answer == "yes":
C print("Go!")
D else:
E print("Wait")
Line B — Python keywords are case sensitive. The keyword must be lowercase: if answer == "yes":

Student with a class code? Join your class →