0% found this document useful (0 votes)
35 views

Python Project pdf3

The document describes a number guessing game that has two modes - one where the user guesses the number selected by the computer and one where the computer guesses the number selected by the user. It provides code to implement the game and functions for each mode along with inputs and outputs. The conclusion discusses how the game fosters skills like critical thinking.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Python Project pdf3

The document describes a number guessing game that has two modes - one where the user guesses the number selected by the computer and one where the computer guesses the number selected by the user. It provides code to implement the game and functions for each mode along with inputs and outputs. The conclusion discusses how the game fosters skills like critical thinking.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

A

PROJECT REPORT
ON
“Number Guessing Game”

SUBMITTED BY

Mr. Paithankar Pratik K. (122)


Under the guidance of

Mr. M. V. Khasane

Department of Computer Technology


Sanjivani Rural Education Society
SANJIVANI K. B. P. POLYTECHNIC
KOPARGAON – 423603, DIST: AHMEDNAGAR
2023-2024

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.

Mr. M. V. Khasane Mr. G. N. Jorvekar


Project guide. H.O.
2
INDEX

SR. NO. TITLE PAGE


NO.
1. Introduction 4

2. Code 5 to 9

3. Output 10

4. Conclusion and References 11

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")

#Function for Number Guessing Computer


def NumberGuessComputer():
# //User Defined Number
UserNumber=input("Enter Your Number That The Computer Should Guess=")
if UserNumber.isdigit():
UserNumber=int(UserNumber)
if UserNumber<=0:
print("enter a number greater than 0 next time")
quit()
else:
print("enter a valid number")
# //Range for Computer to Guess
ComputerRange=input("Enter a range to find the random number=")
if ComputerRange.isdigit():
ComputerRange=int(ComputerRange)
if ComputerRange<=0:
print("enter a number greater than 0 next time")
else:
print("enter a valid number")
low=0
high=ComputerRange

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")

# //function for help


def Help():
print("""
WELCOME TO THE NUMBER GUESSING GAME!
1.Guess The Number Game(User)
Instructions:
1. The computer has selected a random number between a specified range of Levels.
2. Your task is to guess the correct number within a 10 number of attempts.
3. After each guess, the computer will provide feedback to guide you towards the correct
answer.
4. Keep guessing until you correctly identify the number or until you exhaust all your
attempts.

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!

2.Guess The Number Game(Computer)


Instructions:
1. The User has selected a random number between a specified range.
2. Computer task is to guess the correct number within a 10 number of attempts.
3. After each guess, the User will provide feedback to guide Computer towards the correct
answer.
7
4. Keep guessing until you correctly identify the number or until you exhaust all your
attempts.

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!

Are you ready to test your guessing skills? Let's start!


""")
ans=input("Press\n1.To Start The Game\n2.Quit\n")
if ans=='1':
Guess()
elif ans=='2':
quit()
# //Start The Game
def Guess():
print("_______________________NUMBER GUESSING
GAME_______________________")
print("GAME TYPES")
who=input("press\n1.Guess The Number Game(User)\n2.Guess The Number
Game(Computer)\n3.Help\n4.Quit\n")

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

You might also like