← SC in Schools Python

Text Adventure Game Design

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 paths

Understanding Text Adventure Game Design in SC in Schools Python

What it does: Each if/elif branch sends the player down a different path depending on what they typed. while True: creates an infinite loop that keeps asking for input each turn of the game. print() outputs text to the screen. input() waits for the player to type something. input() pauses the game and returns whatever the player types as a string. Planning your rooms and branching paths before coding prevents logic errors and saves time. == is the comparison operator. A single = is assignment and will cause a syntax error in an if condition. input() captures the player's choice so it can be tested in an if/elif/else block.

Common mistakes: The branching logic needs an if statement, not print(). It should be: if choice == "run": with an indented block below. Line 2 is wrong. Python while loops do not have a closing whileEnd keyword. The loop body is defined by indentation alone. Line 3 is wrong.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 64–73) and word search (Modules 64–73).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which function is used to display story text to the player in a text adventure?
print()input()
Matches
if choice = "run":
↓
Wrong — use == for comparison, not = which is assignment
Applying
Meanings
Term
text adventure
Meaning
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 paths
Practice
print("You are at a crossroads.")
Testing
Gaps
choice = ("> ")
Check Answer
Spots
2choice = input("> ")
3print(choice == "run"):

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Star Fox' badge — Frozen Master, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which function is used to display story text to the player in a text adventure?
A. print() ✓
B. input()
print() outputs text to the screen. input() waits for the player to type something.
2. Which function captures the player's choice in a text adventure?
A. input() ✓
B. print()
input() pauses the game and returns whatever the player types as a string.
3. Which keyword structure sends the player down different story paths?
A. while/for
B. if/elif/else ✓
if/elif/else checks the player's choice and runs different code depending on what they typed.
4. What is the purpose of while True: in a text adventure game?
A. To keep the game running in a continuous loop ✓
B. To check if the player's choice is true
while True: creates an infinite loop so the game keeps going until explicitly stopped with break.
5. Should you plan your game's rooms and paths before writing any code?
A. No — just start coding and figure it out as you go
B. Yes — plan on paper first using a map or flowchart ✓
Planning your rooms and branching paths before coding prevents logic errors and saves time.

Match the Pairs

print("You are in a cave.") → Displays the story location and description to the player
choice = input("> ") → Pauses the game and stores whatever the player types as a string
if/elif/else creates branching story paths → if choice == "left": print("Safe!") elif choice == "right": print("Danger!")
while True: keeps the game running until the player quits → while True: choice = input("> ")
if choice = "run": → Wrong — use == for comparison, not = which is assignment
While True: → Wrong — while must be all lowercase; While with a capital W is a syntax error

Key Term

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 paths

Fill in the Blanks

1. print("You are in a forest.") choice = input("> ") if choice == "run":
Hint: Type the function name that captures the player's typed choice
2. print("You are at a door.") if choice == "open": print("You enter the room.")
Hint: Type the function name used to display story text to the player
3. if choice == "left": print("Safe path!") elif choice == "right":
Hint: Type the keyword used to check a second condition after an if
4. while True: print("Game is running.") choice = input("> ")
Hint: Type the value that makes the while loop run continuously
5. if choice == "north": print("A river!") else: print("Invalid.")
Hint: Type the keyword for the fallback branch when no other condition matched

Spot the Error

Question 1
A print("You are in a cave.")
B choice = input("> ")
C print(choice == "run"):
Line C — The branching logic needs an if statement, not print(). It should be: if choice == "run": with an indented block below. Line 2 is wrong.
Question 2
A # Game loop
B while True:
C choice = input("> ")
D whileEnd
Line D — Python while loops do not have a closing whileEnd keyword. The loop body is defined by indentation alone. Line 3 is wrong.
Question 3
A print("You reach a bridge.")
B choice = input("> ")
C if choice = "cross":
Line C — A single = is assignment, not comparison. The condition must use == to compare: if choice == "cross":. Line 2 is wrong.
Question 4
A if choice == "left":
B print("You go left.")
C elif:
D print("Other path.")
Line C — elif must have a condition to test — elif: with no condition is invalid. It should be elif choice == "right": or similar. Line 2 is wrong.
Question 5
A print("A dark corridor.")
B choice = Input("> ")
C if choice == "go":
D print("You walk forward.")
Line B — input() must be all lowercase. Input() with a capital I is not recognised and will cause an error. Line 1 is wrong.

Student with a class code? Join your class →