🚀 Mini Coding Project: Create a Number Guessing Game in Python 🎯🐍

Sarat Parhi  |  June 17,2025 |  4

🚀 Mini Coding Project: Create a Number Guessing Game in Python 🎯🐍

This helps you practice loops, conditionals, and randomness.

🔹 📌 Project Goal:  
The program picks a random number, and the user keeps guessing until they get it right!

🔹 📋 Steps to Build:

⿡ Generate a Random Number  
Use random.randint() to pick a number between 1 and 100

⿢ Take User Input in a Loop  
Ask the user to guess the number

⿣ Give Feedback:  
• “Too high”  
• “Too low”  
• “Correct!”  

🔹 💻 Python Code:

python
import random

number = random.randint(1, 100)
attempts = 0

print("Guess the number between 1 and 100!")

while True:
    guess = int(input("Enter your guess: "))
    attempts += 1

    if guess < number:
        print("Too low! Try again.")
    elif guess > number:
        print("Too high! Try again.")
    else:
        print(f"Correct! You guessed it in {attempts} attempts.")
        break


🔹 ✅ What You’ll Learn:  
• Using loops and break  
• Handling user input  
• Generating random numbers  
• Basic game logic
 

Comments (0)