Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
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 greet(): | ADefines a function named greet. Its code does not run yet. | |
| 2 print("Hi!") | BThe colon is missing at the end of the def line. It should be def greet(): | |
| 3Define the function first, then call it to make the body run. | Cdef say_hello(): print("Hello") | |
| 4A function name is followed by brackets and a colon, and the body is indented. | Ddef cheer(): print("Go!") cheer() | |
| 5def greet() print("Hi!") | EThe function is called before it is defined, so Python gives a NameError. Define it first, then call it. | |
| 6greet() def greet(): print("Hi!") | FAn indented line inside the function body that runs only when the function is called. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
def name(): — Creates a function: a named, reusable block of indented code that only runs when you call it. Define it first, then call it.def greet():
print("Hi!")
greet()def greet():
print("Hello!")
greet()def welcome():
print("Welcome!")
welcome()def say_hi():
print("Hi!")
say_hi()def beep():
print("Beep!")
beep()