← All projects

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

  1. Pick a secret number Use random.seed(42) then random.randint(1, 20) so the answer is repeatable while testing.
  2. Read guesses in a loop Use a while loop, convert input() to int, and count attempts.
  3. Give feedback Print "Too low", "Too high" or "Correct in N tries".
  4. Handle bad input Wrap int() in try/except so letters do not crash the game.

Skills: loops, if/else, random, input