← ACARA Digital Technologies Years 7–8

Scratch My Blocks as Python functions

Makes a Python function, like defining a Scratch My Block once. Run it any time by calling its name, e.g. greet(). Inputs become parameters, so you reuse the code instead of copying blocks.

Understanding Scratch My Blocks as Python functions in ACARA Digital Technologies Years 7–8

What it does: The Scratch block input becomes a parameter inside the brackets of the def line. Calling the same function three times reuses one definition, just like using a My Block three times instead of copying its blocks. The 'define' hat block becomes def. For example, def jump(): is like define jump. Functions let you reuse code. You write the steps once with def, then call the name whenever you need them. A def line must end with a colon. Without the colon Python gives a syntax error.

Common mistakes: Writing only the name does not run the function. Like dragging out a My Block, you must call it with brackets: jump(). The call is missing its closing bracket. The block input 3 must go inside a full pair of brackets: spin(3).

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 522–560) and word search (Modules 522–580).

Take this worksheet further — free with Cloodit

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

Learning
Duo
In Scratch you make a custom block in My Blocks. Which Python keyword does the 'define' hat block turn into?
defblock
Matches
cheer() print('Go team!')
↓
This is missing the def keyword, so Python cannot define the function. It also has no colon, so it is a call, not a definition.
Applying
Meanings
Term
def
Meaning
Makes a Python function, like defining a Scratch My Block once. Run it any time by calling its name, e.g. greet(). Inputs become parameters, so you reuse the code instead of copying blocks.
Practice
def cheer(name):
Testing
Gaps
cheer():
Check Answer
Spots
2 print("Jump!")
3jump

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

The 'Gila Monster' badge — Patient Coder, 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. In Scratch you make a custom block in My Blocks. Which Python keyword does the 'define' hat block turn into?
A. def ✓
B. block
The 'define' hat block becomes def. For example, def jump(): is like define jump.
2. Which line runs (uses) a function called jump, like dragging the jump block into a script?
A. def jump()
B. jump() ✓
Calling a function means writing its name with brackets: jump(). Writing def again would define it a second time instead of running it.
3. You define a Scratch My Block once and use it many times. What is the Python version of this?
A. Copy and paste the same lines every time you need them
B. Define the function once, then call it many times ✓
Functions let you reuse code. You write the steps once with def, then call the name whenever you need them.
4. Which function definition is written correctly in Python?
A. def dance(): ✓
B. def dance()
A def line must end with a colon. Without the colon Python gives a syntax error.
5. A My Block has an input called steps, like 'move (steps)'. How is this input written in Python?
A. def move_forward(steps): ✓
B. def move_forward:steps
Block inputs become parameters. They go inside the brackets after the function name.

Match the Pairs

def cheer(): → Defines a new function called cheer, like making a Scratch My Block with the define hat
cheer() → Calls the function so its code runs, like dragging the My Block into a script
A My Block with an input, like 'jump (height)', becomes a function with a parameter → def jump(height):
Reuse: define once, then use the My Block many times instead of copying blocks → greet() greet() greet()
cheer() print('Go team!') → This is missing the def keyword, so Python cannot define the function. It also has no colon, so it is a call, not a definition.
def cheer(): print('Go team!') cheer → The call is missing brackets, so the function is named but never run.

Key Term

def
Makes a Python function, like defining a Scratch My Block once. Run it any time by calling its name, e.g. greet(). Inputs become parameters, so you reuse the code instead of copying blocks.

Fill in the Blanks

1. def cheer(): print("Go team!")
Hint: Type the keyword that defines a function, like making a new My Block.
2. def cheer(): print("Go team!") cheer()
Hint: Type the punctuation that ends the def line, before the indented body begins.
3. def cheer(): print("Go team!") cheer()
Hint: Type the function name used to call it, like dragging your My Block into a script.
4. def hello(name): print("Hi", name) hello("Zoe")
Hint: Type the parameter, like the input of a My Block, that the function body prints.
5. def bonus(points): print(points + 10) bonus(5)
Hint: Type the arithmetic operator that adds ten to the input value.

Spot the Error

Question 1
A def jump():
B print("Jump!")
C jump
Line C — Writing only the name does not run the function. Like dragging out a My Block, you must call it with brackets: jump().
Question 2
A def spin(times):
B print("Spin", times)
C spin(3
Line C — The call is missing its closing bracket. The block input 3 must go inside a full pair of brackets: spin(3).
Question 3
A def clap():
B print("Clap!"
C clap()
D clap()
Line B — The print call inside the function is missing its closing bracket. It should be print("Clap!").
Question 4
A def move(steps)
B print("Moving", steps)
C move(10)
Line A — The def line must end with a colon. It should be def move(steps):.
Question 5
A function say_hi(name):
B print("Hi", name)
C say_hi("Sam")
Line A — Python uses the keyword def, not function, to define a function (like the define block in Scratch). It should be def say_hi(name):.

Student with a class code? Join your class →