Number Guessing Game Using Python Project Report
Number Guessing Game Using Python Project Report
using Python
IT Engineering
by
CERTIFICATE
This is to certify that the B.Tech. Project entitled “Number Guessing Game using
Navi Mumbai in partial fulfilment of the requirement for the award of the degree of “IT
Examiners
1.---------------------------------------------
2.---------------------------------------------
Date:
Place:
Declaration
We declare that this written submission represents our ideas in our own words and where
others’ ideas or words have been included, we have adequately cited and referenced the original
sources. We also declare that we have adhered to all principles of academic honesty and integrity
and have not misrepresented or fabricated or falsified any idea/data/fact/source in our submission.
We understand that any violation of the above will be cause for disciplinary action by the Institute
and can also evoke penal action from the sources which have thus not been properly cited or from
whom proper permission has not been taken when needed.
---------------------------------------
Signature
Avanish Tiwari (2043110232)
---------------------------------------
Signature
Kaustubh Phadke (2043110233)
---------------------------------------
Signature
Mehak Dhall (2043110223)
---------------------------------------
Signature
Harshada Dixit (2143110243)
Date:
INDEX
1) Abstract
2) Introduction
3) Scope & Purpose
4) Method of Implementation
5) Conclusion
6) Reference
Abstract
Team Member:
1.Avanish Tiwari (2043110229)
2.Kaustubh Phadke (2043110231)
3.Mehak Dhall (2043110223)
4. Harshada Dixit (2143110243)
Language:
Python
Ide:
VS Code
Introduction:-
Number Guessing Game using Python is the application is mostly used
guessing game.
This is going to be a simple guessing game where the computer will
generate a random number between 1 to 100, and the user has to guess it
in 4 attempts
Bases on the user’s guess computer will give various hints if the number
is high or low. When the user guess watches the number computer will
print the answer along with the number of attempts
Purpose:-
The number guessing game is a popular game among programmers. In
the number guessing game, the program selects a random number
between two numbers, and the user guesses the correct number. If you
want to learn how to create a guessing game using Python, this Project is
for you. In this Project, I will take you through a tutorial on creating a
number guessing game using the Python programming language.
Task:-
• Build a Number guessing game, in which the user selects a range.
• Let’s say User selected a range, i.e., from A to B, where A and B belong
to Integer.
• Some random integer will be selected by the system and the user has to
guess that integer in the minimum number of guesses
Method Of Implementation:-
• If the User inputs range, let’s say from 1 to 100. And compiler randomly
selected 42 as the integer. And now the guessing game started, so the user
entered 50 as his/her first guess. The compiler shows "Too high!"
• That’s mean the random number (i.e., 42) doesn’t fall in the range from
50 to 100. That’s the importance of guessing half of the range. And again,
the user guesses half of 50 (Could you tell me why?). So the half of 50 is
25. The user enters 25 as his/her second guess. This time compiler will
show, "Too low"
• That’s mean the integers less than 25 (from 1 to 25) are useless to be
guessed. Now the range for user guessing is shorter, i.e., from 25 to 50.
Intelligently! The user guessed half of this range, so that, user guessed 37
as his/her third guess. This time again the compiler shows the output,
"Too low"
• For the user, the guessing range is getting smaller by each guess. Now,
the guessing range for user is from 37 to 50, for which the user guessed
43 as his/her fourth guess. This time the compiler will show an output
"Too high!"
• So, the new guessing range for users will be from 37 to 43, again for
which the user guessed the half of this range, that is, 40 as his/her fifth
guess. This time the compiler shows the output, "Too low“
• Leaving the guess even smaller such that from 41 to 43. And now the
user guessed 41 as his/her sixth guess. Which is wrong and shows
output . And finally, the User Guessed the right number which is 42 as
his/her seventh guess.
Algorithm:-
Steps:_
• User inputs the lower bound and upper bound of the range.
• The compiler generates a random integer between the range and store it in
a variable for future references.
• For repetitive guessing, a while loop will be initialized.
• If the user guessed a number which is greater than a randomly selected
number, the user gets an output "Too high!"
• Else If the user guessed a number which is smaller than a randomly
selected number, the user gets an output "Too low"
• And if the user guessed in a minimum number of guesses, the user gets a
"you guessed it right!!" Output.
Code:-
import random
n = random.randrange(1,100)
guess = int(input("Enter any number: "))
while n!= guess:
if guess < n:
print("Too low")
guess = int(input("Enter number again: "))
elif guess > n:
print("Too high!")
guess = int(input("Enter number again: "))
else:
break
print("you guessed it right!!")
Conclusion:-
So this is how you can write a program to create a guessing game using Python.
It is a popular game among programmers. In this game, the program selects a
random number between two numbers, and the user guesses the correct number.
I hope you liked this presentation on how to create a guessing game using
Python. Feel free to ask valuable questions.
Reference :-
https://thecleverprogrammer.com/2022/06/29/number-guessing-
game-using-python/