CHAPTER 9: FINAL PROJECT

The Mind Reader 🔮

It's time to become a Master Coder! We will build a game where the computer thinks of a secret number, and you have to guess it.

🛠️ The Blueprint

  • 1️⃣ Import Random: Get the magic library.
  • 2️⃣ Secret Number: Pick a number 1-10.
  • 3️⃣ Input: Ask the player to guess.
  • 4️⃣ Logic: Check if they won!

BUILD THE GAME 🏗️

Step 1: The Secret

Import random and pick a number between 1 and 10.

import random
secret = random.randint(1, 10)
print(secret)

For finding bugs, print it!

Waiting for you to run code...

Step 2: The Guess

Ask the player for a number. Remember int()!

guess = int(input("Guess a number (1-10): "))
Locked 🔒

Step 3: Win or Lose

Use if and else to check if guess == secret.

if guess == secret:
    print("You won!")
else:
    print("Try again!")
Locked 🔒
⌨️ GAME FACTORY
Waiting...