A Project Report on
NUMBER GUESSING GAME USING PYTHON
BACHELOR OF COMPUTER APPLICATION
By
Samardeep Singh
AJU/230454
Under the guidance of
Mr. Debanjan Ghosh
(Assistant Professor)
&
DR. Arvind Kumar Pandey
(Dean)
ARKA JAIN UNIVERSITY, JHARKHAND
DEPARTMENT OF COMPUTER SCIENCE & INFORMATION TECHNOLOGY
1
CERTIFICATE
This is to certify that the project entitled “NUMBER GUESSING GAME” in
PYTHON is bonafide work of Samardeep Singh bearing enrolment number:
AJU/230454 under the guidance of Dean Dr. Arvind Kumar Pandey and Mr. Debanjan
Ghosh submitted in partial fulfilments of the requirement for the award of degree in
BACHELOR OF COMPUTER APPLICATION from ARKA JAIN UNIVERSITY,
JHARKHAND during the year 2024-2025.
Dr. Arvind Kumar Pandey
Dean
School of Engineering and IT
ARKA JAIN UNIVERSITY
Jharkhand
[Link]@[Link]
2
ABSTRACT
The Number Guessing Game is a fun and interactive Python-based project designed to test a
player's ability to predict a randomly selected number within a given range. The game generates a
random number and prompts the player to make guesses while providing real-time feedback on
whether their guess is too high, too low, or correct. By utilizing fundamental programming concepts
such as loops, conditionals, user input handling, and random number generation, this project serves
as an excellent learning experience for beginners.
To enhance the user experience, the game can be customized with various difficulty levels, attempt
limits, and scoring mechanisms that reward efficient guessing. Additional features such as a
leaderboard, timed challenges, or multiplayer mode can also be integrated to increase engagement.
This project not only introduces players to logical problem-solving but also encourages incremental
improvements in programming skills, making it a valuable exercise for those new to Python.
3
ACKNOWLEDGEMENT
The journey to completing this project was challenging and rewarding, marked by countless learning
experiences and moments of growth. It is often said that success is not achieved alone, and this
project is no exception. The guidance, support, and encouragement from knowledgeable individuals
were crucial in navigating the complexities and obstacles encountered along the way. I am highly
obliged to express my deep sense of gratitude and thanks to my erudite guide, Mr . Debanjan Ghosh,
for her valuable guidance and support, which led to the successful and timely completion of my
project report. I am also very thankful to our Dean, Dr. Arvind Kumar Pandey, Department of
Bachelor in Computer Applications, for his valuable suggestions and guidance. Last but not least, I
deeply appreciate the cheerful encouragement of all the staff members of my department and my
friends.
4
DECLARATION
I, SAMARDEEP SINGH, hereby declare that the project entitled “Number Guessing Game” done at
ARKA JAIN UNIVERSITY has not been duplicated in any way for submission to any other
university for the award of any degree. To the best of my knowledge, no one other than myself has
submitted this project to any other university.
This project is done in partial fulfillment of the requirements for the award of the degree of
BACHELOR OF COMPUTER APPLICATION, to be submitted as a Second Year, 4nd Semester
project.
SAMARDEEP SINGH
AJU/230454
5
CONTENT
LIST OF CONTENTS PAGE
NO.
INTRODUCTION 07
SPECIFICATION REQUIREMENT 08
CODE 09-11
OUTPUT 12
CONCLUSION 13
REFERENCE 14
6
7
INTRODUCTION
The Number Guessing Game is an interactive Python project designed to test a player's ability to
predict a randomly generated number within a predefined range. This game offers an engaging way
to develop problem-solving skills while reinforcing fundamental programming concepts such as
loops, conditionals, functions, and user input handling.
The game consists of three key functions:
1. difficulty() – This function prompts the player to choose between two difficulty levels:
o Easy Mode – Players receive 10 attempts to guess the correct number.
o Hard Mode – Players have only 5 attempts, making the game more challenging.
2. easy_level() – This function manages the game logic for Easy Mode, where the player gets
more attempts, making it suitable for beginners or those looking for a more relaxed
experience.
3. hard_level() – This function implements the Hard Mode, where players must be more
strategic with their guesses since they have fewer chances to win.
Once a difficulty level is chosen, the game generates a random number, and the player must guess it
within the allowed number of attempts. After each guess, the game provides immediate feedback,
indicating whether the guess is too high, too low, or correct. If the player runs out of attempts
without guessing the number, the game reveals the correct answer and ends.
This project is an excellent way for beginners to strengthen their Python programming skills in a fun
and interactive manner. The game can be further enhanced by adding features such as a dynamic
difficulty setting, hints, a scoring system, or even a multiplayer mode to make it more engaging. By
building and playing this game, learners can improve their logical thinking and algorithmic skills
while gaining hands-on experience with Python functions and control structures.
7
SYSTEM REQUIRMENTS
1. Used Hardware Configuration List
⮚ processor-intel®core™i5-12355U CPU @ 3.50GHz. 3.50GHz
⮚ RAM- 16GB
⮚ SSD- 512GB
2. Used Software list
⮚ For execution of code – Visual Studio Code (for python)
⮚ For execution of code – pycharm
⮚ For the presentation of code Ms word
3. Operating system
⮚ Windows 10 pro, version: 22H2
8
CODE
import random
print("Welcome to the Number Guessing Game!")
print("I am thinking of a number between 1 to 100.")
enter = input("Choose a difficulty level. Type 'easy' or 'hard': ").lower()
lives_easy = 10
lives_hard = 5
guess = [Link](1, 100)
#print(guess)
def difficulty():
if enter == "easy":
print(f"You selected {enter} mode. You have {lives_easy} attempts.")
return lives_easy
elif enter == "hard":
print(f"You selected {enter} mode. You have {lives_hard} attempts.")
return lives_hard
else:
print("Invalid choice. Defaulting to 'easy' mode.")
return lives_easy
9
attempts = difficulty()
make = int(input("Make a guess: "))
def check_easy(attempts, make):
"""Handles easy mode with 10 attempts"""
for i in range(attempts, 0, -1):
print(f"You have {i} attempts left to guess the number correctly!")
if make == guess:
print(f" You guessed the correct number! The number is {guess}.")
return
elif make < guess:
print(f"Too low! You have {i-1} attempts left. Your guess was {make}.")
else:
print(f"Too high! You have {i-1} attempts left. Your guess was {make}.")
if i > 1:
make = int(input("Enter your new guess: "))
print(f"You have run out of attempts. The number was {guess}. Better luck next time!")
def check_hard(attempts, make):
"""Handles hard mode with 5 attempts"""
for i in range(attempts, 0, -1):
print(f"You have {i} attempts left to guess the number correctly!")
10
if make == guess:
print(f"You guessed the correct number! The number is {guess}.")
return
elif make < guess:
print(f"Too low! You have {i-1} attempts left. Your guess was {make}.")
else:
print(f"Too high! You have {i-1} attempts left. Your guess was {make}.")
if i > 1:
make = int(input("Enter your new guess: "))
print(f"You have run out of attempts. The number was {guess}. Better luck next time!")
if enter == "easy":
check_easy(attempts, make)
elif enter == "hard":
check_hard(attempts, make)
else:
check_easy(attempts, make)
11
OUTPUT
Easy mode
Hard mode
12
CONCLUSION
The Number Guessing Game in Python is a simple yet effective project that reinforces fundamental
programming concepts such as loops, conditionals, functions, and user input handling. By
implementing different difficulty levels, the game offers a balanced challenge for both beginners and
experienced players. The structured approach, with separate functions for difficulty selection and
gameplay, ensures clarity and modularity in the code.
Through this project, players not only engage in a fun guessing challenge but also develop logical
thinking and problem-solving skills. The game can be further enhanced by adding features such as a
scoring system, leaderboard, hints, or even a multiplayer mode to increase engagement. Additionally,
modifying the game to include dynamic difficulty or adaptive AI-based hints can make it even more
interactive and educational.
Overall, the Number Guessing Game serves as an excellent beginner-friendly project that provides a
hands-on learning experience in Python programming. It demonstrates how simple concepts can be
combined to create an interactive application, paving the way for more complex projects in the
future. Whether for learning or entertainment, this game remains a great example of how
programming can be both educational and enjoyable.
13
REFERENCES
[1] Deitel, P., & Deitel, H. (2017). python: How to Program. Prentice Hall.
[2] Horstmann, C. S. (2017). Core Java Volume I – Fundamentals. Prentice Hall.
[3] Schildt, H. (2018). Java: The Complete Reference. McGraw-Hill Education
[4] Gamma, E., Helm, R., Johnson, R., & Vlissides, J. (1994). Design Patterns: Elements of Reusable
Object-Oriented Software. Addison-Wesley.
[5] Fowler, M. (2002). Patterns of Enterprise Application Architecture. Addison-Wesley.
[6] W3Schools. (n.d.). python Tutorial. Retrieved from
[7] GeeksforGeeks. (n.d.). python Programming Language. Retrieved from
[Link]
14