Skip to content

Project 2: Guess the number 2.0

In Module 03 you wrote “Guess the number.” Now let’s turn it into a real game: the program gives a hint after every wrong guess and tells you how many tries it took.

  1. Start with secret = 7 and tries = 0
  2. Read the first guess (int(input(...))) and count the try
  3. while guess != secret: — until it’s found:
    • if the guess is less than the secret: “The secret number is higher ⬆️”
    • if it’s greater: “The secret number is lower ⬇️”
    • read a new guess, count the try again
  4. When the loop ends: f"You found it in {tries} tries 🎉"
Mission

Guess the number 2.0

+25 XP

Follow the plan. (The player’s scenario is in the inputs: 3 → higher, 9 → lower, 6 → higher, 7 → found it! The program should say 4 tries at the end.)

Inputs (for input())

One value per line — read in order by input().

Output
 

Next project: build your own quiz — questions in a list, points on a counter. Continue →