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 save_scores(): pass | AA comment that marks work still to do, so developers can find it later and replace the stub with real code. | |
| 2# TODO: add validation | Bclass Player: pass # TODO: add attributes | |
| 3A stub can return a fixed test value so the rest of the program can be tested before the real calculation is written. | CThe stub is replaced by real code but pass was left in. It is now unnecessary and misleading, so delete pass when the real code goes in. | |
| 4A stub for a class uses pass as its body, so objects can be created before its attributes and methods are written. | DThe function has no body. A comment is not a statement, so Python raises an IndentationError. Add an indented pass line. | |
| 5def load_data(): # TODO: read the file | Edef get_total(): return 100 # TODO: real total | |
| 6def show_menu(): pass print('Menu') | FA stub function: it has a name but an empty body, so the program runs while the real code is still to be written. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
pass — A Python statement that does nothing. It fills a stub's empty body, often beside a # TODO comment, so the program still runs while the real code is written later.def total():
# TODO: add up prices
passdef save():
# TODO: write to file
passdef getmark():
# TODO: read the mark
passdef price(item):
# TODO: look up price
return 9.99def double(n):
# stub was: pass
return n * 2