Skip to content

Perfect guess Game

Pre-release
Pre-release

Choose a tag to compare

@AbhijeetKumar1505 AbhijeetKumar1505 released this 13 Sep 18:15
974b787

Perfect Guess

"Perfect Guess" is a simple yet engaging number-guessing game where your challenge is to find the secret number between 1 and 100. The game randomly selects a number, and your task is to guess it in as few attempts as possible. After each guess, you'll receive a hint—whether to guess higher or lower—bringing you closer to the correct answer.

If you're spot on, the game will congratulate you, letting you know how many attempts it took. Feeling competitive? Try to beat your previous score by guessing the number in fewer attempts. You can play as many rounds as you like, but if you wish to stop, simply type "0" to exit the game.

Features:

Random number selection between 1 and 100.
Hints provided after each guess to guide you.
Unlimited attempts with feedback on performance.
Option to exit the game at any time.
Simple and intuitive gameplay, perfect for quick fun or a longer challenge.
Test your intuition, refine your guessing skills, and see if you can achieve the perfect guess!

`import random

command = "START"

while command != "EXIT":
n = random.randint(1, 100)
guesses = 0
a = None

while a != n:
    
    a = int(input("Guess the Number (or type '0' to exit): "))
    if a == 0:
        print("Exiting the game.")
        command = "EXIT"
        break
    guesses += 1
    if a not in range(1,101):
        print("Invalid input. Please enter a valid number.")
        break
    if a > n:
        print("Lower number please!")
    elif a < n:
        print("Higher number please!")

if a == n:
    print(f"Congratulations! You've guessed the number {n} correctly in {guesses} attempts.")

if command != "EXIT":
    choice = input("Do you want to play again? (YES/NO): ").upper()
    if choice != "YES":
        command = "EXIT"

print("Thank you for playing!")
`

Screen.Recording.2024-09-13.233411.mp4

Full Changelog: https://github.com/AKsince2005/python/commits/#fun-project