Beginner project · about 25 minutes
Number Guessing Game 🎯
Your first real program: loops, conditions and random numbers in a game people will actually play.
Games are the best way to learn control flow. You will build a game that picks a secret number and gives hot/cold hints. Because the runner cannot wait for a human, the guesses arrive through the "Program input" box (one per line).
What you will build
- Pick a secret number Use random.seed(42) then random.randint(1, 20) so the answer is repeatable while testing.
- Read guesses in a loop Use a while loop, convert input() to int, and count attempts.
- Give feedback Print "Too low", "Too high" or "Correct in N tries".
- Handle bad input Wrap int() in try/except so letters do not crash the game.
Skills: loops, if/else, random, input