π―
Guess my number
Play a guessing game against a random secret number.
BuilderΒ· ages 10β1225 minimportrandomif / elif / elsef-strings
guess.py
β¦First load pulls ~10Β MB of Python. Only happens once β the browser caches it after.
What should the output look like?
Change my_guess and rerun until you win β the output tells you whether to go higher or lower.
π
How this works
The computer picks a random secret number. You have to guess it. if / elif / else compares your guess to the secret and prints one of three messages β win, too low, or too high.
Your turn β try these
- 1Uncomment the loop at the bottom. How many tries does the computer need?
- 2Add a hint that tells the player how CLOSE they were (within 5, within 10).
- 3Change the range to 1..1000. Does the same guess still work?