0% found this document useful (0 votes)
7 views18 pages

Python Number Guessing Game Project

The document is a project report on a 'Number Guessing Game' created using Python, submitted by Ayush Paikaray from Kendriya Vidyalaya Puri for the academic session 2024-2025. It includes sections such as an abstract, introduction, system requirements, source code, and conclusion, highlighting the game's functionality and educational value in programming. The project demonstrates the application of Python programming concepts like user input, conditionals, and random number generation to create an interactive game.

Uploaded by

ayushpaikaray666
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views18 pages

Python Number Guessing Game Project

The document is a project report on a 'Number Guessing Game' created using Python, submitted by Ayush Paikaray from Kendriya Vidyalaya Puri for the academic session 2024-2025. It includes sections such as an abstract, introduction, system requirements, source code, and conclusion, highlighting the game's functionality and educational value in programming. The project demonstrates the application of Python programming concepts like user input, conditionals, and random number generation to create an interactive game.

Uploaded by

ayushpaikaray666
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PM Shri Kendriya Vidyalaya Puri

COMPUTER SCIENCE PROJECT


SESSION: 2024 - 2025

A PROJECT ON
“NUMBER GUESSING GAME”

Submitted By Submitted To
Name : Shradhanjali Singh
Ayush Paikaray_- 16 PGT(Computer Science)
Class: XI A

PM Shri Kendriya Vidyalaya Puri,


Odisha -752002
Certificate
This is to certify that (Ayush Paikaray) students of
class XI-A have succesfully prepared the report on the
Project entitle “Number Guessing Game.” under the
guidance of (Shradhanjali Singh) (PGT Computer Science).

The report acceptance as Final Project Report for the


subject Computer Science of Class XI-A (Science).

__________________________
Signature of Principal
(Principal)

__________________________
Signature of Internal Examiner
(Shradhanjali Singh)
PGT-Computer Science
Acknowledgement

I would like to express a deep sence of thanks and


gratitude to my project guide (Teacher) for guiding me
immensely through the project. She always evinced keen
interest in my project. Her Constructive advice and
constant motivation have been responsible for successful
completion of this project.

My sincere thanks go to (Principal) sir for this co-


ordination in extending every possible support for the
completion of this project.

I must thanks to my classmate for their timely help and


support for completion of this project.

Last but not the least, I would like to thank all those
who had helped directly and indirectly towards the
completion of this project.

Name:
Ayush Kumar Paikaray - 16
Class: XI A

Subject: Computer Science


Table of Contents

[Link]. Description Page

1 Certificate 2

2 Acknowledgement 3

3 Table of Contents 4

4 Abstract 5

5 Introduction 6

6 Systen Requirements of project 7

7 Sourse Code 8

8 Code In Run 9

9 Output 10

10 Conclusion 11
Abstract

Team Member:
[Link] Kumar Paikaray

Brief information regarding project:


Python program to create a Number Guessing Game using
Python programming concepts.

This is a project report on “Number Guessing Game using


Python” it is a python program based game which is
created for the purpose of entertainment. This python
program contain basics of python such as user input,
while condition, if- else condition.

Basic logic behind the game is that the system will ask
about a number and then according to the users input it
will gives output such as ‘Too low’ or ‘Too High’ and
when the number is guessed correct it will show output
as ‘you guesed it right!’. And this number will be
random and will depends on the random fuction which is
used in python program.

Language: Python

IDE: VS Code
Introduction
What is Python ?
Python is a high-level programming language which
makes the code very easy to read and understand. With
no need for declaration of variables, parameters and
functions, Python’s codes are usually shorter
compared to other programming languages. Python is
great language for beginners as it has a simple
syntaxand is easy to read.

What is Number Guessing Game?


A number guessing game in Python is a simple game
where the computer generates a random number, and the
player tries to guess it. The program provides
feedback to the player indicating whether their guess
is ‘too high’ or ‘too low’. This continues until the
player correctly guesses the number.

We wish you the best from the depth of our


hearts that you guess the number in First Try.
System Requirement of Project

[Link] Title:
“NUMBER GUESSING GAME”

[Link]:
“PYTHON”

[Link] and Software Requirement:


Operating system:- Window XP, 7, 8 or above
RAM:- 2GB or above
Software:- PYTHON IDLE or VS Code or any python
compiler
Processor:- 2.0 GH2 or above
Hard Drive Space:- 2GB or above
Source Code
import tkinter as tk
from tkinter import ttk, messagebox
import random
import winsound # Only works on Windows. For cross-platform, consider using other
libraries like pygame.

class GuessTheNumberGame:
def __init__(self, root):
[Link] = root
[Link]("Guess the Number Game")
[Link]("400x350")
[Link](False, False)
self.number_to_guess = [Link](1, 100)
[Link] = 0
self.high_score = None # Initialize high score to None

self.create_menu()
self.create_widgets()
self.load_high_score()

def create_menu(self):
menubar = [Link]([Link])
[Link](menu=menubar)

game_menu = [Link](menubar, tearoff=0)


menubar.add_cascade(label="Game", menu=game_menu)
game_menu.add_command(label="New Game", command=self.reset_game)
game_menu.add_separator()
game_menu.add_command(label="Exit", command=[Link])

help_menu = [Link](menubar, tearoff=0)


menubar.add_cascade(label="Help", menu=help_menu)
help_menu.add_command(label="How to Play", command=self.show_help)
help_menu.add_command(label="About", command=self.show_about)
def create_widgets(self):
main_frame = [Link]([Link], padding="10")
main_frame.pack(fill=[Link], expand=True)

self.welcome_label = [Link](main_frame, text="Welcome to Guess the Number


Game!", font=("Helvetica", 16))
self.welcome_label.pack(pady=10)

self.instruction_label = [Link](main_frame, text="Guess a number between 1 and


100:", font=("Helvetica", 12))
self.instruction_label.pack(pady=5)

[Link] = [Link](main_frame, font=("Helvetica", 12))


[Link](pady=5)
[Link]("<Return>", lambda event: self.check_guess())

self.guess_button = [Link](main_frame, text="Guess", command=self.check_guess)


self.guess_button.pack(pady=5)

self.result_label = [Link](main_frame, text="", font=("Helvetica", 12))


self.result_label.pack(pady=5)

self.attempts_label = [Link](main_frame, text="Attempts: 0", font=("Helvetica", 12))


self.attempts_label.pack(pady=5)

[Link] = [Link](main_frame, orient="horizontal", length=300,


mode="determinate")
[Link](pady=10)
self.update_progress()

self.high_score_label = [Link](main_frame, text="High Score: N/A", font=("Helvetica",


12))
self.high_score_label.pack(pady=5)

self.restart_button = [Link](main_frame, text="Restart Game",


command=self.reset_game)
self.restart_button.pack(pady=5)
self.restart_button.config(state=[Link])
def play_sound(self, sound_type):
if sound_type == "correct":
[Link](winsound.MB_OK)
elif sound_type == "low":
[Link](winsound.MB_ICONQUESTION)
elif sound_type == "high":
[Link](winsound.MB_ICONEXCLAMATION)

def check_guess(self):
try:
guess = int([Link]())
[Link] += 1
self.attempts_label.config(text=f"Attempts: {[Link]}")
self.update_progress(guess)

if guess < self.number_to_guess:


self.result_label.config(text="Too low!", foreground="blue")
self.play_sound("low")
elif guess > self.number_to_guess:
self.result_label.config(text="Too high!", foreground="blue")
self.play_sound("high")
else:
[Link]("Congratulations!", f"Correct! You guessed it in
{[Link]} attempts.")
self.result_label.config(text=f"Correct! The number was {self.number_to_guess}.",
foreground="green")
[Link](state=[Link])
self.guess_button.config(state=[Link])
self.restart_button.config(state=[Link])
self.play_sound("correct")

# Update high score if necessary


if self.high_score is None or [Link] < self.high_score:
self.high_score = [Link]
self.high_score_label.config(text=f"High Score: {self.high_score}")
self.save_high_score()
except ValueError:
[Link]("Invalid input", "Please enter a valid number.")
def reset_game(self):
self.number_to_guess = [Link](1, 100)
[Link] = 0
[Link](state=[Link])
[Link](0, [Link])
self.result_label.config(text="", foreground="black")
self.attempts_label.config(text="Attempts: 0")
self.guess_button.config(state=[Link])
self.restart_button.config(state=[Link])
self.update_progress()
self.welcome_label.config(text="New Game! Guess a number between 1 and 100:")

def update_progress(self, guess=None):


[Link]['value'] = 0 if guess is None else (guess / 100) * 100

def load_high_score(self):
try:
with open("high_score.txt", "r") as file:
self.high_score = int([Link]().strip())
self.high_score_label.config(text=f"High Score: {self.high_score}")
except (FileNotFoundError, ValueError):
self.high_score = None

def save_high_score(self):
with open("high_score.txt", "w") as file:
[Link](str(self.high_score))

def show_help(self):
[Link]("How to Play", "Guess the number between 1 and 100. You will
receive feedback whether your guess is too high or too low. Try to guess the correct
number in as few attempts as possible.")

def show_about(self):
[Link]("About", "Guess the Number Game\nVersion 1.0\nCreated by
[Your Name]")

if __name__ == "__main__":
root = [Link]()
game = GuessTheNumberGame(root)
[Link]()
Code In Run
INPUT:
Output
conclusion

The Number Guessing Game project demonstrates how


fundamental concepts of Python, such as conditional
statements, loops, user input handling, and random
number generation, can be applied to create an
interactive and engaging program. This project not only
enhances programming logic but also improves problem-
solving skills by implementing user interaction and
error handling.

Through the development of this game, we gain insights


into the importance of planning, debugging, and refining
code. Such small-scale projects serve as a foundation
for more advanced programming tasks, helping learners
build confidence in writing code independently. This
game can further be improved by adding features like
difficulty levels, scoring systems, or a graphical user
interface (GUI).

Overall, this project highlights the practical


applications of Python and reinforces the value of
hands-on learning in computer science.
Reference

GeeksforGeeks:
[Link]
guessing-game-in-python/

GitHub:
[Link]
Guessing-Game

Scribd:
[Link]
umber-Guessing-Game-using-Python-project-
report-2

NCERT Computer Science Textbook


Thank You

You might also like