├── README.md └── test.py /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Guess the Number Game 🎮 3 | A fun and interactive Python game where the computer picks a random number, and your mission is to guess it! Get helpful hints like "Too high!" or "Too low/" until you find the right number. Perfect for practicing Python skills! 🚀✨= 4 | -- 5 | 6 | ## Features 🛠️ 7 | 8 | - 🎲 Random number generation ensures a unique game every time. 9 | - 🔄 Unlimited guesses with instant feedback on each attempt. 10 | - 🎯 Tracks the number of guesses, so you can aim for a better score. 11 | 12 | --- 13 | 14 | ## How to Play 🕹️ 15 | 16 | 1. Clone the repository and navigate to the project folder. 17 | 2. Run the script using Python: 18 | ```bash 19 | cd randome.py 20 | 3. link 21 | ```bash 22 | https://github.com/abderrahmane-laourf/random-python.git 23 | 24 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def guess_the_number(): 4 | print("Welcome to 'Guess the Number' game!") 5 | print("I'm thinking of a number between 1 and 100.") 6 | 7 | # Generate a random number 8 | number_to_guess = random.randint(1, 100) 9 | attempts = 0 10 | 11 | while True: 12 | try: 13 | user_guess = int(input("Take a guess: ")) 14 | attempts += 1 15 | 16 | if user_guess < number_to_guess: 17 | print("Too low! Try again.") 18 | elif user_guess > number_to_guess: 19 | print("Too high! Try again.") 20 | else: 21 | print(f"Congratulations! You guessed the number in {attempts} attempts.") 22 | break 23 | except ValueError: 24 | print("Please enter a valid number.") 25 | 26 | 27 | guess_the_number() 28 | --------------------------------------------------------------------------------