This is a fun and simple Python game where the computer randomly picks a number, and the user has to guess what it is. The goal is to guess the correct number in as few tries as possible.
When the program starts, it asks the user to enter a maximum number. The computer then randomly picks a secret number between 0 and that maximum number.
The user is then asked to make a guess. After each guess:
- If the guess is too low, the program says "You are below the number!"
- If the guess is too high, it says "You are above the number!"
- If the guess is correct, it says "You got it!" and ends the game
The program also counts how many guesses the user makes and shows the total number at the end.
- Takes a custom top number from the user
- Picks a random number each time
- Gives hints to guide the user (higher or lower)
- Tells how many guesses were made
- Uses basic Python functions and logic
This project helps beginners understand:
input()
andprint()
functions- Using
if
,elif
, andelse
statements while True
loops- Random number generation using
random.randint()
- Basic error handling