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 main(): greet() | Adef main(): get_name() show_menu() | |
| 2def area(w, h): return w * h | Bgreet is missing its brackets, so the helper function is never called. It should be greet(). | |
| 3A decomposition box called 'Show the score' becomes its own function that main() can call | CThe main function calls the greet function, so main uses greet as a helper to do one job | |
| 4A big problem is split up so main() calls one small helper function for each sub-problem | Dshow_score() is called but was never defined with def, so Python gives a NameError. Define the helper first. | |
| 5def main(): greet main() | EA small helper function that does just one job: work out an area and give it back | |
| 6def main(): show_score() main() | Fdef show_score(score): print(score) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
def main(): greet() — A function can call another function inside its body. Big problems get split into small helper functions that each do one job, like boxes in a decomposition.def cheer(): print("Go!")
def main(): cheer()def main():
greet()
goodbye()def show(n): print(n * n)
def main(): show(5)def add(a, b): return a + b
def main(): print(add(2, 3))
main()def area(w, h): return w * h
def main(): print(area(3, 4))