VOD-ZalHD

🔹 Introduction

The current image has no alternative text. The file name is: ZAL.jpg

The Number Guessing Game is a classic beginner Python project.

  • The computer randomly picks a number.
  • The player tries to guess it.
  • The program gives hints if the guess is too high or too low.
  • The game continues until the player guesses correctly.

🔹 Code Example

import random

print("🎮 Welcome to the Number Guessing Game!")
print("I am thinking of a number between 1 and 100.")

# Generate a random number
secret_number = random.randint(1, 100)

# Track attempts
attempts = 0
guessed = False

while not guessed:
    try:
        guess = int(input("👉 Enter your guess: "))
        attempts += 1

        if guess < secret_number:
            print("📉 Too low! Try again.")
        elif guess > secret_number:
            print("📈 Too high! Try again.")
        else:
            print(f"🎉 Congratulations! You guessed the number {secret_number} in {attempts} attempts.")
            guessed = True
    except ValueError:
        print("⚠️ Please enter a valid number.")

🔹 Example Run

🎮 Welcome to the Number Guessing Game!
I am thinking of a number between 1 and 100.
👉 Enter your guess: 50
📉 Too low! Try again.
👉 Enter your guess: 75
📈 Too high! Try again.
👉 Enter your guess: 62
📉 Too low! Try again.
👉 Enter your guess: 68
🎉 Congratulations! You guessed the number 68 in 4 attempts.

🔹 Concepts Learned
  • random.randint() → generates random numbers.
  • while loop → repeat until condition is true.
  • if/elif/else → decision-making.
  • Exception handling → avoid crashes with invalid input.

🔹 Summary
  • Created a Number Guessing Game using Python.
  • Practiced random module, loops, conditionals, and error handling.
  • This project can be extended (e.g., adding difficulty levels, limited attempts, or scoring system).
⬇️ Download VOD-ZalHD تحميل Server 1 ⬇️ Download VOD-ZalHD تحميل Server 2

Related Posts

Rapid_tv

🔹 Introduction The Rock, Paper, Scissors Game is a classic hand game that you can easily build in Python. 👉 Rules: 🔹 Code Example 🔹 Example Run 🔹 Concepts Learned…

Read more

Delux_pro

🔹 Introduction The To-Do List App is one of the most popular beginner projects. It teaches you how to: 🔹 Code Example 🔹 Features of This App 🔹 Example Run…

Read more

Fam4k

🔰 Project Overview A calculator is one of the simplest yet most effective projects to start with in Python.You will learn: ✍️ Step 1: Plan the Calculator We need: 🖥️…

Read more

Speed_HD+

1. Introduction Data visualization helps us understand patterns and insights in data by converting raw numbers into charts and graphs.In Python, the most popular libraries are: 2. Installing Required Libraries…

Read more

Dauo

1. Introduction Web scraping is the process of extracting data from websites. In Python, we commonly use libraries like requests (to fetch web pages) and BeautifulSoup (to parse and extract…

Read more

Macia_Pro

1. What is an API? 2. The requests Library The most common library for working with APIs in Python. Install if needed: 3. Making a GET Request ✅ GET requests…

Read more