Python Project pdf3
Python Project pdf3
PROJECT REPORT
ON
“Number Guessing Game”
SUBMITTED BY
Mr. M. V. Khasane
1
Sanjivani Rural Education Society’s
SANJIVANI K.B.P POLYTECHNIC
DEPARTMENT OF COMPUTER TECHNOLOGY
CERTIFICATE
This is to certify that the Project report entitled
“Number Guessing Game”
Submittedby:
Mr. Paithankar Pratik K. (122)
Under our supervision and guidance for partial fulfillment of the
requirement for
DIPLOMA IN COMPUTER TECHNOLOGY affiliated to
Maharashtra State Board of Technical Education, Mumbai For
academic year 2023-2024.
2. Code 5 to 9
3. Output 10
3
INTRODUCTION
Number Guessing Game offers two exciting modes: "Guess The Number Game(User)"
and "Guess The Number Game(Computer)."
In the "Guess The Number Game(User)" mode, the computer selects a random number
within a specified range based on the chosen difficulty level: Easy, Medium, or Hard.
Your task is to guess the correct number within a maximum of 10 attempts. After each
guess, the computer will provide feedback to help you narrow down your choices. Keep
guessing until you find the correct number or exhaust all your attempts.
In the "Guess The Number Game(Computer)" mode, you select a random number within
a specified range, and the computer attempts to guess it within a maximum of 10 attempts.
After each guess, you provide feedback to guide the computer towards the correct answer.
The computer adjusts its guesses based on your feedback until it either finds the number
or reaches the maximum number of attempts.
The key to success in both modes is strategic guessing and using the feedback provided
to your advantage. The fewer attempts you take, the better your score!
4
CODE
import random
#Function for user Guessing Game
def NumberGuessUser():
range=0
Level=input('''
Select The Level
Press
E.Easy
M.Medium
H.Hard\n''').lower()
match(Level):
case 'e':
range=30
case 'm':
range=50
case 'h':
range=100
UserRandom=random.randint(0,range)
choise=0
while True:
user_input=input("enter a choice between 0 to %d="%range)
choise=choise+1
if choise>=10:
print("GAME OVER! You Lost Plz try again")
quit()
if user_input.isdigit():
user_input=int(user_input)
else:
print("enter a valid number")
continue
if(user_input==UserRandom):
print("Congratulations you guess it right in %d chances"%choise)
choise=0
break
elif user_input<UserRandom:
5
print("sorry guess again! Too Low")
elif user_input>UserRandom:
print("Sorry the guess! To High")
Guide=""
chance=0
while Guide !='c':
ComputerRandom=random.randint(low,high)
Guide=input(f"Is {ComputerRandom} too High(H), too Low(L) ,
Correct(C)").lower();
chance=chance+1
if chance>=10:
print("GAME OVER! 3You Lost Plz try again")
quit()
6
if Guide=="h":
print("Entered Number is Too Hign")
high=ComputerRandom-1
elif Guide=="l":
print("Entered Number is Too Low")
low=ComputerRandom+1
elif UserNumber==ComputerRandom:
if Guide=='c':
if chance==1:
print(f"Congratulations You Guessed it Correct in {chance} Chance")
else:
print(f"Congratulations You Guessed it Correct in {chance} Chances")
Hints:
- The computer will inform you if your guess is too high or too low.
- Use the feedback to adjust your subsequent guesses strategically.
- Remember, the fewer attempts you take, the better your score!
Hints:
- The User will inform you if your guess is too high or too low.
- Use the feedback to adjust your subsequent guesses strategically.
- Remember, the fewer attempts you take, the better your score!
match(who):
case "1":
NumberGuessUser()
case "2":
NumberGuessComputer()
case "3":
Help()
case "4":
quit()
# //Guess
Guess()
8
OUTPUT
10
11
12
CONCLUSION
In conclusion, the Number Guessing Game offers an immersive and dynamic gaming
experience that appeals to players of all ages. Whether you opt for the challenge of
guessing the computer's selected number or guiding the computer to guess yours, the
game provides a platform for strategic thinking, logical deduction, and quick
decisionmaking. With each guess, players receive valuable feedback that aids in refining
their approach and narrowing down the possibilities. The thrill of anticipation builds
with every attempt, creating an atmosphere of excitement and suspense. Furthermore,
the game's limit of 10 attempts adds an element of urgency, motivating players to think
carefully and act decisively. Overall, the Number Guessing Game fosters cognitive
skills, encourages critical thinking, and delivers endless entertainment. So, whether
you're a seasoned player seeking a new challenge or a newcomer eager to test your luck,
dive into the world of number guessing and embark on an unforgettable journey of
discovery. Let your intuition guide you, and may the thrill of the hunt lead you to
victory! Are you ready to embrace the challenge and unleash your inner strategist? Let
the guessing games begin, and may the odds be ever in your favor!
REFERENCES
1. https://www.w3schools.com/python/python_functions.asp
2. https://www.geeksforgeeks.org/python-if-else/
13