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.
- Start with
secret = 7andtries = 0 - Read the first guess (
int(input(...))) and count the try 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
- When the loop ends:
f"You found it in {tries} tries 🎉"
Mission
Section titled “Mission”Guess the number 2.0
+25 XP ✓ CompletedFollow 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 →