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 | |
|---|---|---|
| 1print("You are in a cave.") | Aif choice == "left": print("Safe!") elif choice == "right": print("Danger!") | |
| 2choice = input("> ") | BPauses the game and stores whatever the player types as a string | |
| 3if/elif/else creates branching story paths | CDisplays the story location and description to the player | |
| 4while True: keeps the game running until the player quits | Dwhile True: choice = input("> ") | |
| 5if choice = "run": | EWrong — while must be all lowercase; While with a capital W is a syntax error | |
| 6While True: | FWrong — use == for comparison, not = which is assignment |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
text adventure — A type of program where the player reads story text and types choices; built using print() for output, input() for choices, and if/elif/else for branching pathsprint("You are in a forest.")
choice = input("> ")
if choice == "run":print("You are at a door.")
if choice == "open":
print("You enter the room.")if choice == "left":
print("Safe path!")
elif choice == "right":while True:
print("Game is running.")
choice = input("> ")if choice == "north":
print("A river!")
else:
print("Invalid.")