Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Scratch My Blocks as Python functions worksheet is part of the ACARA Digital Technologies Years 7–8 — Programming with Control Structures and Functions (Python) journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1def cheer(): | AThe call is missing brackets, so the function is named but never run. | |
| 2cheer() | Bgreet() greet() greet() | |
| 3A My Block with an input, like 'jump (height)', becomes a function with a parameter | CThis is missing the def keyword, so Python cannot define the function. It also has no colon, so it is a call, not a definition. | |
| 4Reuse: define once, then use the My Block many times instead of copying blocks | DDefines a new function called cheer, like making a Scratch My Block with the define hat | |
| 5cheer() print('Go team!') | Edef jump(height): | |
| 6def cheer(): print('Go team!') cheer | FCalls the function so its code runs, like dragging the My Block into a script |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
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.def cheer():
print("Go team!")def cheer():
print("Go team!")
cheer()def cheer():
print("Go team!")
cheer()def hello(name):
print("Hi", name)
hello("Zoe")def bonus(points):
print(points + 10)
bonus(5)