import random
# READING QUEST
# A simple educational reading game
levels = [
{
"name": "Beginner Reader",
"story": (
"The cat sat on a mat. "
"The cat saw a little bird."
),
"questions": [
{
"question": "Where did the cat sit?",
"options": ["A. A chair", "B. A mat", "C. A tree"],
"answer": "B",
"explanation": "The story says the cat sat on a mat."
},
{
"question": "What animal did the cat see?",
"options": ["A. A dog", "B. A fish", "C. A bird"],
"answer": "C",
"explanation": "The cat saw a little bird."
}
]
},
{
"name": "Story Explorer",
"story": (
"Maya planted a seed in her garden. "
"She watered it every morning. "
"After many days, a green plant appeared."
),
"questions": [
{
"question": "What did Maya plant?",
"options": ["A. A seed", "B. A stone", "C. A flower"],
"answer": "A",
"explanation": "Maya planted a seed."
},
{
"question": "When did Maya water the seed?",
"options": [
"A. Every night",
"B. Every morning",
"C. Every week"
],
"answer": "B",
"explanation": "She watered it every morning."
},
{
"question": "What appeared after many days?",
"options": [
"A. A bird",
"B. A new house",
"C. A green plant"
],
"answer": "C",
"explanation": "A green plant appeared."
}
]
}
]
def show_progress(score, total):
print(f"\nā Score: {score}/{total}")
def play_level(level, total_score):
score = 0
lives = 3
print("\n" + "=" * 40)
print(f"LEVEL: {level['name']}")
print("=" * 40)
print("\nš READ THIS STORY:\n")
print(level["story"])
input("\nPress Enter when you are ready to answer...")
questions = level["questions"].copy()
random.shuffle(questions)
for item in questions:
if lives == 0:
print("\nYou have used all your lives!")
break
print("\n" + item["question"])
for option in item["options"]:
print(option)
choice = input("Your answer (A, B, or C): ").strip().upper()
while choice not in ("A", "B", "C"):
choice = input(
"Please enter A, B, or C: "
).strip().upper()
if choice == item["answer"]:
print("Correct! š Well done!")
score += 10
else:
lives -= 1
print("Not quite! ā¤ļø")
print("Hint:", item["explanation"])
print(f"Lives remaining: {lives}")
total_score += score
print("\nLevel complete!")
show_progress(score, len(level["questions"]) * 10)
print(f"š Total points: {total_score}")
return total_score, lives
def main():
print("š® WELCOME TO READING QUEST!")
player = input("What is your name? ").strip()
if not player:
player = "Reader"
total_score = 0
print(f"\nWelcome, {player}! Let's improve your reading.")
for index, level in enumerate(levels):
total_score, lives = play_level(level, total_score)
if lives == 0:
print("\nGame over! Keep practising and try again.")
break
if index < len(levels) - 1:
print("\nš Great job! The next level is unlocked.")
input("Press Enter to continue...")
print("\n" + "=" * 40)
print(f"Thanks for playing, {player}!")
print(f"FINAL SCORE: {total_score} points")
print("Keep reading and keep learning! š")
print("=" * 40)
if __name__ == "__main__":
main()
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Hello, world</title>
</head>
<body>
<main>
<h1>Hello, world.</h1>