Adventure Story Program in Python - A Step-by-Step Guide
Adventure Story Program in Python - A Step-by-Step Guide
Objective:
You will create an adventure story program using Python. This program will include various elements such
as comments, strings, print statements, user input, conditional statements (if, elif, else), random choices,
booleans, and library imports.
● Example format:
# Adventure Story Program # Author: Your Name # Date: Today's Date # Description: A simple
adventure story that allows the user to make choices.
import random
● Example:
intro = "Welcome to the Adventure! You are in a dark forest." choice1 = "Do you want to go left or
right?"
● Example:
print(intro) print(choice1)
Step 6: Get User Input
● Use the input() function to ask the user for their choices.
● Example:
● Example:
● Example:
outcomes = ["You win a prize!", "You fall into a trap!", "You find a magic potion!"]
print(random.choice(outcomes))
● Example:
has_key = True # This means the user has a key to open a door.
● Example:
● Conditional Statements: A way to execute different code based on certain conditions (if, elif, else).
Good luck with your adventure story program! Remember to take it one step at a time.