0% found this document useful (0 votes)
3 views47 pages

Class 12 Cs

The document is a project report for a Hangman game developed using Python's Tkinter library, submitted for the CBSE Senior Secondary Certificate. It includes sections such as introduction, system analysis, modules used, and the game's algorithm, showcasing its educational value and programming concepts. The game features multiple difficulty levels, word categories, and an interactive GUI, making it accessible for users of all skill levels.

Uploaded by

zynex190
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)
3 views47 pages

Class 12 Cs

The document is a project report for a Hangman game developed using Python's Tkinter library, submitted for the CBSE Senior Secondary Certificate. It includes sections such as introduction, system analysis, modules used, and the game's algorithm, showcasing its educational value and programming concepts. The game features multiple difficulty levels, word categories, and an interactive GUI, making it accessible for users of all skill levels.

Uploaded by

zynex190
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

Project report on

HANGMAN GAME

SUBMITTED IN PARTIAL FULFILMENT OF THE


AWARD OF
CBSE Senior Secondary Certificate
2025-26
Done by
Name: ……………………………………
REG No: …………………………………

UNDER THE GUIDENCE OF


[Link] M, PGT COMPUTER SCIENCE

KENDRIYA VIDYAALAY EZHIMALA

1
KENDRIYA VIDYALAYA EZHIMALA

CERTIFICATE
Certify that the project entitled “ HANGMAN GAME ”
is a project done by
Name: ………………………………
REG no.: ……………………………

During the period of 2025-26 of his/her study in this school under the
guidance of Mr. Shaji.M , PGT computer science in partial fulfilment
of the requirement for the CBSE Senior Secondary Certificate
Submitted for practical examination held on ………………..

Project guide Teacher-in-charge

External examiner Principal

2
DECLERATION
I ………………………..…. REG no:………….…. herby declare that
the project entitled “ Hangman Game ” is the result of original work
done by me during the period of study in class XII of computer science,
KENDRIYA VIDHYALA EZHIMALA under the supervision and
guidance of Mr. Shaji.M , PGT Computer Science

This project is submitted in fulfilment of the requirement for the award


of CBSE Senior Secondary Certificate.

Place: Signature:

Date:

3
ACKNOWLEDGEMENT

I express my sincere thanks to Principal of our Vidyalaya, who has


created conductive atmosphere to finish my project in time.
A sincere and true world of thanks to [Link].M, PGT Computer
Science for his valuable suggestions, guidance and encouragement.
I thank all my sincere friends who helped me for the successful
completion of the project.
Last but not the least I would like to thank the almighty and my parents
for showering their blessings on me

4
ABSTRACT
This project implements a Hangman word game using Python’s Tkinter
library for CBSE Class 11. Players guess letters to reveal a hidden word
before the hangman drawing is complete. The game features:

- Three difficulty levels (Easy, Medium, Hard)


- Different word categories (Animals, Fruits, Colors)
- Visual hangman drawing that progresses with wrong guesses
- Letter tracking and attempt counter

Developed with standard Python libraries, it demonstrates fundamental


programming concepts while providing an engaging learning tool. The
intuitive interface makes it accessible for all users.

5
INDEX
[Link] TITLE PAGE
NO.
1 INTRODUCTION 7

2 SYSTEM ANALYSIS 8

3 SYSTEM CONFIGURATION 9

4 DEVELOPMENT MACHINE 10

5 MODULES USED 13

6 ALGORITHM 14

7 THE CODE 18

8 HOW TO RUN THIS CODE 39

9 CONCLUSION 41

10 FURTHER DEVELOPMENT 42

11 SCREEN LAYOUT 43

12 BIBLIOGRAPHY 47

6
INTRODUCTION

This project presents a Python-based Hangman game developed using


the Tkinter library. The program provides an interactive platform for
users to test their vocabulary skills through the classic word-guessing
gameplay of Hangman.

The game offers multiple difficulty levels and word categories, allowing
players to customize their experience. A visual hangman drawing
progressively appears with each incorrect guess, while correctly guessed
letters are revealed in the hidden word. The interface displays guessed
letters and remaining attempts to help players strategize.

Built entirely with Python’s standard libraries, this implementation


demonstrates core programming concepts including variables, control
structures, functions, and event-driven GUI development. The project
aligns with the CBSE Class 12 Computer Science curriculum
requirements, serving as both an educational tool and entertaining game.

The simple yet engaging design makes the game accessible to users of
all skill levels while effectively showcasing fundamental programming
principles through practical application.

7
SYSTEM ANALYSIS

Existing System
Traditional Hangman games require physical materials, manual word
selection by players, and lack standardized rules or difficulty levels. The
hand-drawn nature leads to inconsistent visuals and no progress
tracking.

Proposed System
This digital implementation features:
 Automation: Random word selection from categorized lists
 GUI: Tkinter-based interface with interactive elements
 Visuals: Progressive hangman drawing (6 stages)
 Gameplay:
-Three difficulty levels
- Attempt counter
-Win/lose detection

Advantages
1. No physical materials required
2. Standardized rules and visuals
3. Adjustable difficulty
4. Built-in progress tracking

8
SYSTEM CONFIGURATION

HARDWARE:
• Intel Core i5-12450H Processor
• 16GB LPDDR5 RAM
• 512GB SSD Storage
• 15.6" FHD (1920×1080) Display

SOFTWARE:
• Windows 11 Home 64-bit
• Python 3.13.5
• PyCharm Community Edition 2023.1

9
DEVELOPMENT MACHINE

Windows 11:
Windows 11 features major changes to the Windows shell influenced by
the cancelled Windows 10X, including a redesigned Start menu, the
replacement of its "live tiles" with a separate "Widgets" panel on the
taskbar, the ability to create tiled sets of windows that can be minimized
and restored from the taskbar as a group, and new gaming technologies
inherited from Xbox Series X and Series S such as Auto HDR and
DirectStorage on compatible hardware. Internet Explorer (IE) has been
replaced by the Chromium-based Microsoft Edge as the default web
browser, like its predecessor, Windows 10, and Microsoft Teams is
integrated into the Windows shell. Microsoft also announced plans to
allow more flexibility in software that can be distributed via the
Microsoft Store and to support Android apps on Windows 11 (including
a partnership with Amazon to make its app store available for the
function).

Citing security considerations, the system requirements for Windows 11


were increased over Windows 10. Microsoft only officially supports the
operating system on devices using an eighth-generation Intel Core CPU
or newer (with some minor exceptions), a second-generation AMD
Ryzen CPU or newer, or a Qualcomm Snapdragon 850 ARM system-
on-chip or newer, with UEFI and Trusted Platform Module (TPM) 2.0
supported and enabled (although Microsoft may provide exceptions to
the TPM 2.0 requirement for OEMs). While the OS can be installed on
unsupported processors, Microsoft does not guarantee the availability of

10
updates. Windows 11 removed support for 32-bit x86 and 32-bit ARM
CPUs and devices that use BIOS firmware.

Windows 11 has received a mostly positive reception. Pre-release


coverage of the operating system focused on its stricter hardware
requirements, with discussions over whether they were legitimately
intended to improve the security of Windows or as a ploy to upsell
customers to newer devices and over the e-waste associated with the
changes. Upon release, it was praised for its improved visual design,
window management, and stronger focus on security, but was criticized
for various modifications to aspects of its user interface that were seen
as worse than its predecessor; some were seen as an attempt to dissuade
users from switching to competing applications.

By December 2020, Microsoft had begun to implement and announce


some of these visual changes and other new ‘features on Windows 10
Insider Preview builds, such as new system icons (which also included
the replacement of shell resources dating back as far as Windows 95),
[34] improvements to Task View to allow changing the wallpaper on
each virtual desktop, x86-64 emulation on ARM, and adding the Auto
HDR feature from Xbox Series X.

On May 18, 2021, Head of Windows Servicing and Delivery John Cable
stated that Windows 10X had been cancelled and that Microsoft would
be “accelerating the integration of key foundational 10X technology into
other parts of Windows and products at the company”.

11
Python:
Python is a high-level, general-purpose programming language. Its
design philosophy emphasizes code readability with the use of
significant indentation.

Guido van Rossum began working on Python in the late 1980s as a


successor to the ABC programming language and first released it in
1991 as Python 0.9.0.[34] Python 2.0 was released in 2000. Python 3.0,
released in 2008, was a major revision not completely backward
compatible with earlier versions. Python 2.7.18, released in 2020, was
the last release of Python 2.

Python is dynamically typed, and garbage collected. It supports multiple


programming paradigms, including structured (particularly procedural),
object-oriented and functional programming. It is often described as a
"batteries included" language due to its comprehensive standard library.

12
MODULES USED

1. tkinter: This is the core module used for creating the main
Graphical User Interface (GUI), managing windows,
frames, labels, and the drawing canvas.

2. customtkinter: This library is used to provide a more


modern look for the buttons, featuring rounded corners and
custom hover effects that standard tkinter does not offer.

3. random: This module is essential for the game's core


mechanic, as it randomly selects a "secret word" from the
predefined lists based on the player's chosen difficulty and
category.

4. messagebox: Imported from tkinter, this is used to generate


the standard pop-up notifications for game events.

13
ALGORITHM
The game follows this structured logic flow:

I. Preliminary Setup & Resource Allocation


1. Library Invocation: Load tkinter for base-level GUI,
customtkinter for high-fidelity widget rendering, and random for
cryptographic-standard word randomization.
2. Data Architecture Design: Define a nested, multi-dimensional
dictionary (word_lists).
o Level 1 (Complexity): Segregate by Easy, Medium, and
Hard.
o Level 2 (Thematic): Sub-categorize into Animals, Fruits,
and Countries.
3. Variable Initialization:
o Initialize secret_word (String) and guessed_letters (List).
o Set chances_left to a constant of 6 and hangman_stage to 0.
o Establish is_popup_open (Boolean) as a semaphore to
control thread-like event handling.

II. GUI Construction & Responsive Design


1. Dynamic Environment Scaling:
o Calculate screen_width and screen_height using window
methods.
o Define font sizes using a scalar multiplier relative to the
vertical resolution to ensure cross-device consistency.

14
2. Frame Controller Logic:
o State 1 (Difficulty Screen): Render branding elements
(Title, Subtitle, Emoji) and difficulty selection triggers.
o State 2 (Category Screen): Programmatically generate
buttons based on the dictionary keys of the selected
difficulty.
o State 3 (Active Gameplay): Execute a split-pane layout
using [Link] objects.

III. The Core Procedural Game Loop


1. Word Extraction: Invoke select_word() to grab a target string.
2. String Masking Logic:
o Iterate through the secret_word.
o If a character is present in guessed_letters, append the
character to a display string; otherwise, append an
underscore (_).
3. The Input Pipeline (make_guess):
o Trigger: Listen for <Return> keypress or "Guess" button
click.
o Sanitization Phase: Normalize the entry via .lower() and
.strip() to remove case-sensitivity and accidental
whitespace.
o Validation Gatekeeping:
 Reject input if it is non-alphabetic or contains
multiple characters.
 Reject input if it exists within the guessed_letters
array.

15
o State Modification:
 Mismatch: If the guess is incorrect, decrement
chances_left, increment hangman_stage, and trigger
flash_canvas_red() for haptic-style visual feedback.
 Canvas Rendering: Update the vector graphics on
the Canvas based on the new hangman_stage index.

IV. Vector Graphic Rendering Logic


1. The Coordinate System: Define a fixed coordinate system for
the Canvas object.
2. Step-wise Drawing:
o Stage 1: Base gallows (Lines).
o Stage 2: Head (Oval).
o Stage 3: Torso (Line).
o Stages 4–6: Appendages (Diagonal Lines).
o

V. Termination, Safety, and Cleanup


1. End-of-Life Logic (check_game_status):
o Win Condition: Scan the display string for underscores. If
null, invoke the Win Sequence.
o Loss Condition: Evaluate chances_left. If zero, invoke the
Loss Sequence.
2. Widget Security: Set guess_entry state to "disabled" to prevent
post-game logical errors.
3. Modal Window Management:
o Instantiate a Toplevel popup.

16
o Use grab_set() to lock the main window focus.
o Use attributes("-topmost", True) to ensure the dialog stays
above the fullscreen game.
4. Memory Reclamation (reset_game):
o Wipe the Canvas using .delete("all").
o Clear the guessed_letters list.
o Restore widget states to "normal" and apply focus_set() to
the entry field for immediate replayability.

17
THE CODE

import tkinter as tk
import customtkinter as ctk
from tkinter import messagebox
import random

word_lists = {
"Easy": {
"Animals":
["cat","dog","cow","rat","hen","pig","bat","ant","fox","lion","frog","duck","wolf
","goat"],
"Fruits":
["apple","mango","kiwi","pear","plum","grape","lemon","banana","orange","pap
aya"],
"Countries":
["india","china","japan","france","germany","italy","spain","russia","brazil","can
ada","egypt","mexico"]
},
"Medium": {
"Animals":
["zebra","horse","tiger","sheep","panda","camel","otter","eagle","whale","shark"
,"rabbit","turtle","monkey","donkey","cobra"],
"Fruits":
["cherry","lychee","mulberry","blueberry","strawberry","blackberry","watermelo
n","avocado"],
"Countries":
["greece","turkey","sweden","norway","kenya","thailand","switzerland","poland
","bhutan"]

18
},
"Hard": {
"Animals":
["chimpanzee","hippopotamus","rhinoceros","armadillo","crocodile","platypus",
"orangutan","porcupine","axolotl","aardvark","alligator","salamander","flamingo
","koala","anaconda"],
"Fruits":
["pomegranate","dragonfruit","gooseberry","elderberry","huckleberry","breadfru
it","ackee","salak","longan","rambutan"],
"Countries":
["liechtenstein","seychelles","eswatini","mauritania","brunei","vanuatu","djibout
i","nauru","palau"]
}
}

current_difficulty = ""
current_topic = ""
secret_word = ""
guessed_letters = []
chances_left = 6
hangman_stage = 0

window = [Link]()
[Link]("Hangman Game")

screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()

19
[Link]('-fullscreen', True)

[Link]("<Escape>", lambda e: [Link]('-fullscreen', False))

big_font = int(screen_height * 0.07)


normal_font = int(screen_height * 0.035)
smaller_font = int(screen_height * 0.025)

[Link](bg="#121212")

is_popup_open = False

def draw_hangman():
"""Draws the hangman figure based on current stage (0-6)"""
[Link]("all")

canvas.create_line(25, 480, 225, 480, width=4, fill="#dddddd")


canvas.create_line(125, 480, 125, 100, width=4, fill="#dddddd")
canvas.create_line(125, 100, 245, 100, width=4, fill="#dddddd")
canvas.create_line(245, 100, 245, 160, width=4, fill="#dddddd")

if hangman_stage >= 1: # Head


canvas.create_oval(220, 160, 270, 210, width=4, outline="#dddddd")
if hangman_stage >= 2: # Body
canvas.create_line(245, 210, 245, 330, width=4, fill="#dddddd")
if hangman_stage >= 3: # Left arm

20
canvas.create_line(245, 230, 195, 280, width=4, fill="#dddddd")
if hangman_stage >= 4: # Right arm
canvas.create_line(245, 230, 295, 280, width=4, fill="#dddddd")
if hangman_stage >= 5: # Left leg
canvas.create_line(245, 330, 195, 400, width=4, fill="#dddddd")
if hangman_stage >= 6: # Right leg (game over)
canvas.create_line(245, 330, 295, 400, width=4, fill="#dddddd")

def flash_canvas_red():
"""Visual feedback for wrong guess - flashes canvas red briefly"""
original_color = canvas["bg"]
[Link](bg="#7f1d1d")
[Link](100, lambda: [Link](bg=original_color))

def show_word():
"""
Displays the word with guessed letters shown and unguessed as underscores
Returns the display string without spaces
"""
display = ""
for letter in secret_word:
if letter in guessed_letters:
display += letter + " "
else:
display += "_ "
word_label.config(text=display)

21
return [Link](" ", "")

def update_guessed_display():
"""Updates the label showing all guessed letters"""
guessed_text = ", ".join(sorted(guessed_letters))
guessed_label.config(text=f"Guessed letters: {guessed_text}")

def info_popup(title, message):


global is_popup_open
is_popup_open = True

popup = [Link](window)
[Link](title)
[Link](bg="#121212")
[Link]("-topmost", True)

w, h = 400, 200
x = (popup.winfo_screenwidth() // 2) - (w // 2)
y = (popup.winfo_screenheight() // 2) - (h // 2)
[Link](f"{w}x{h}+{x}+{y}")

[Link](popup, text=message, font=("Arial", 16),


bg="#121212", fg="white", wraplength=350).pack(pady=30)

def close_and_unlock(event=None):
global is_popup_open

22
is_popup_open = False
[Link]()
guess_entry.focus_set()

ok_btn = [Link](popup, text="OK", command=close_and_unlock,


width=100)
ok_btn.pack(pady=10)

ok_btn.focus_set()
[Link]("<Return>", close_and_unlock)

[Link](window)
popup.grab_set()

def game_over_popup(title, message):


popup = [Link](window)
[Link]("WM_DELETE_WINDOW", lambda: None)
[Link](title)
[Link](bg="#121212")
popup.update_idletasks()
w, h = 420, 260
x = (popup.winfo_screenwidth() // 2) - (w // 2)
y = (popup.winfo_screenheight() // 2) - (h // 2)

[Link](f"{w}x{h}+{x}+{y}")
[Link](False, False)

23
[Link](window)
popup.grab_set()

[Link](
popup,
text=message,
font=("Arial", 18),
bg="#121212",
fg="white",
wraplength=380,
justify="center"
).pack(pady=30)

btn_frame = [Link](popup, bg="#121212")


btn_frame.pack(pady=20)

def play_again():
[Link]()
reset_game()

def back_home():
[Link]()
show_difficulty_screen()

def exit_game():

24
[Link]()

[Link](
btn_frame,
text="Play Again",
command=play_again,
width=140,
height=40,
fg_color="#3b82f6"
).pack(pady=6)

[Link](
btn_frame,
text="Back to Home",
command=back_home,
width=140,
height=40,
fg_color="#374151"
).pack(pady=6)

[Link](
btn_frame,
text="Exit",
command=exit_game,
width=140,
height=40,

25
fg_color="#7f1d1d"
).pack(pady=6)

def check_game_status():
current = show_word()

if "_" not in current:


guess_entry.config(state="disabled")

[Link](200, lambda: game_over_popup(

"You Win 🎉",

f"🎉🎉You guessed it🎉🎉!\nThe word was: {secret_word}"


))

elif chances_left <= 0:


guess_entry.config(state="disabled")
[Link](200, lambda: game_over_popup(

"Game Over 💀",


f"You lost!\nThe word was: {secret_word}"
))

def reset_game():
"""Resets the game state for a new round"""
global guessed_letters, chances_left, hangman_stage

guessed_letters = []

26
chances_left = 6
hangman_stage = 0

if current_topic and current_difficulty:


select_word()

draw_hangman()
show_word()
update_guessed_display()
chances_label.config(text=f"Chances left: {chances_left}")

guess_entry.config(state="normal")
guess_entry.delete(0, [Link])
guess_entry.focus_set()

def select_word():
"""Randomly selects a word from the chosen difficulty and topic"""
global secret_word
secret_word = [Link](word_lists[current_difficulty][current_topic])
topic_label.config(text=f"Topic: {current_topic} | Difficulty:
{current_difficulty}")

def make_guess(event=None):
global is_popup_open, chances_left, hangman_stage

if is_popup_open or guess_entry.cget("state") == "disabled":

27
return

guess = guess_entry.get().lower().strip()
guess_entry.delete(0, [Link])

if not [Link]() or len(guess) != 1:

info_popup("Invalid Input", "Please enter a single letter! 🔠")


return

if guess in guessed_letters:

info_popup("Already Guessed", "You've already tried this letter! 🔁")


return

guessed_letters.append(guess)
update_guessed_display()

if guess not in secret_word:


chances_left -= 1
flash_canvas_red()
hangman_stage += 1
draw_hangman()
chances_label.config(text=f"Chances left: {chances_left}")

show_word()
check_game_status()

28
def select_difficulty(difficulty):
"""Called when player selects a difficulty level"""
global current_difficulty
current_difficulty = difficulty
update_category_buttons()
show_category_screen()

def select_topic(topic):
"""Called when player selects a category/topic"""
global current_topic
current_topic = topic
select_word()
reset_game()
show_game_screen()

def update_category_buttons():
"""Dynamically creates category buttons based on selected difficulty"""

for widget in category_buttons_frame.winfo_children():


[Link]()

[Link](category_buttons_frame,
text=f"Select Category ({current_difficulty})",
font=("Arial", normal_font),
bg="#121212",
fg="#dddddd").pack(pady=40)

29
for topic in word_lists[current_difficulty]:
btn = [Link](
category_buttons_frame,
text=topic,
command=lambda t=topic: select_topic(t),
font=("Arial", int(normal_font * 1.2), "bold"),
width=350,
height=70,
corner_radius=200,
fg_color="#3b82f6",
hover_color="#2563eb",
text_color="white"
)
[Link](pady=20)

back_btn = [Link](
category_buttons_frame,
text="← Back to Difficulties",
command=show_difficulty_screen,
font=("Arial", 16),
width=200,
height=40,
corner_radius=100,
fg_color="#374151",
hover_color="#4b5563",

30
text_color="white"
)
back_btn.pack(pady=30)

def show_difficulty_screen():
"""Shows the difficulty selection screen"""
difficulty_frame.pack()
category_frame.pack_forget()
game_frame.pack_forget()

def show_category_screen():
"""Shows the category selection screen"""
difficulty_frame.pack_forget()
category_frame.pack()
game_frame.pack_forget()

def show_game_screen():
"""Shows the main game screen"""
difficulty_frame.pack_forget()
category_frame.pack_forget()
game_frame.pack(fill="both", expand=True)

difficulty_frame = [Link](window, bg="#121212")

title_container = [Link](difficulty_frame, bg="#121212")


title_container.pack(pady=30)

31
[Link](title_container,
text="H A N G M A N",
font=("Arial Black", 70, "bold"),
bg="#121212",
fg="#3b82f6").pack()

[Link](title_container,
text="━━━━━ The Classic Word Game ━━━━━",
font=("Arial", 18),
bg="#121212",
fg="#6b7280").pack(pady=(10, 0))

[Link](title_container,

text="🎮",
font=("Arial", 40),
bg="#121212",
fg="#6b7280").pack(pady=(5, 0))

[Link](difficulty_frame,
text="Choose Difficulty:",
font=("Arial", normal_font),
bg="#121212",
fg="#dddddd").pack(pady=40)

for difficulty in word_lists:

32
btn = [Link](
difficulty_frame,
text=difficulty,
command=lambda d=difficulty: select_difficulty(d),
font=("Arial", int(normal_font * 1.2), "bold"),
width=350,
height=70,
corner_radius=200,
fg_color="#3b82f6",
hover_color="#2563eb",
text_color="white"
)
[Link](pady=20)

category_frame = [Link](window, bg="#121212")

cat_title_container = [Link](category_frame, bg="#121212")


cat_title_container.pack(pady=(40, 10))

[Link](cat_title_container,
text="H A N G M A N",
font=("Arial Black", 70, "bold"),
bg="#121212",
fg="#3b82f6").pack()

[Link](cat_title_container,

33
text="━━━━━ The Classic Word Game ━━━━━",
font=("Arial", 18),
bg="#121212",
fg="#6b7280").pack(pady=(10, 0))

[Link](cat_title_container,

text="🎮",
font=("Arial", 40),
bg="#121212",
fg="#6b7280").pack(pady=(5, 0))

category_buttons_frame = [Link](category_frame, bg="#121212")


category_buttons_frame.pack()
category_buttons_frame = [Link](category_frame, bg="#121212")
category_buttons_frame.pack()

game_frame = [Link](window, bg="#1e1e1e")

top_frame = [Link](game_frame, bg="#1e1e1e")


top_frame.pack(fill="x", pady=20)

topic_label = [Link](top_frame,
text="",
font=("Arial", 36, "bold"),
bg="#1e1e1e",
fg="#dddddd")

34
topic_label.pack()

back_button = [Link](
top_frame,
text="← Back to Categories",
command=show_category_screen,
font=("Arial", 16),
width=200,
height=40,
corner_radius=100,
fg_color="#374151",
hover_color="#4b5563",
text_color="white"
)
back_button.place(x=20, y=20)

main_game_area = [Link](game_frame, bg="#1e1e1e")


main_game_area.pack(expand=True, fill="both", padx=50, pady=30)

canvas = [Link](main_game_area,
bg="#121212",
width=350,
height=500,
highlightthickness=2,
highlightbackground="#444444")
[Link](side="left", padx=40, pady=10)

35
right_panel = [Link](main_game_area, bg="#1e1e1e")
right_panel.pack(side="left", fill="both", expand=True, padx=40)

guess_frame = [Link](right_panel, bg="#1e1e1e")


guess_frame.pack(pady=100)

[Link](guess_frame,
text="Enter a letter:",
font=("Arial", 24),
bg="#1e1e1e",
fg="#dddddd").pack(side="left", padx=10)

guess_entry = [Link](
guess_frame,
width=3,
font=("Arial", 36),
justify="center",
bg="#2e2e2e",
fg="white",
insertbackground="white",
highlightthickness=1,
highlightbackground="#444444",
relief="flat"
)
guess_entry.pack(side="left", padx=15)

36
guess_entry.bind("<Return>", lambda event: make_guess())

guess_btn = [Link](
guess_frame,
text="Guess",
command=make_guess,
font=("Arial", 18, "bold"),
width=120,
height=40,
corner_radius=200,
fg_color="#3b82f6",
hover_color="#2563eb",
text_color="white"
)
guess_btn.pack(side="left", padx=15)

word_label = [Link](right_panel,
font=("Courier", 56, "bold"),
bg="#1e1e1e",
fg="white")
word_label.pack(pady=40)

info_frame = [Link](right_panel, bg="#1e1e1e")


info_frame.pack(pady=40)

chances_label = [Link](info_frame,

37
text="Chances left: 6",
font=("Arial", 24),
bg="#1e1e1e",
fg="white")
chances_label.pack(pady=10)

guessed_label = [Link](info_frame,
text="Guessed letters: ",
font=("Arial", 20),
bg="#1e1e1e",
fg="white")
guessed_label.pack(pady=10)

show_difficulty_screen()
[Link]()

38
HOW TO RUN THIS CODE

Technical Guide: Environment Setup and Execution


To run this advanced Hangman system, the user must ensure that the
Python interpreter is correctly configured and all third-party UI
dependencies are installed. Follow these steps for a successful
deployment:

1. Prerequisites: Python Installation


Before executing the script, a Python 3.x environment must be present
on the system.
 Verification: Open your terminal or command prompt and type:

python --version
 Download: If not installed, download the latest version from

[Link]. Ensure the "Add Python to PATH" checkbox is


selected during installation.

2. Dependency Management (Library Installation)


Your code utilizes customtkinter, which is not part of the standard
Python library. It must be installed via the Python Package Index (PyPI).
 Command: Open your terminal and run the following:

Bash
pip install customtkinter

3. Script Preparation
1. File Saving: Copy the source code and save it into a file named
hangman_game.py.
2. Resource Integrity: Ensure the file is saved with UTF-8
encoding to support the emojis used in the UI.

4. Execution Methods
There are two primary ways to launch your project:

39
Method A: Using an Integrated Development Environment (IDE)
 Open the file in VS Code, PyCharm, or IDLE.

 Press the F5 key or click the "Run" button.

Method B: Using the Command Line (Professional Way)


 Navigate to the folder where the file is saved.

 Type the following command and hit Enter: python


hangman_game.py

5. Operational Instructions (How to Play)


Once the application launches, the system follows this operational flow:
1. Fullscreen Transition: The game will automatically take over the
screen. If you need to exit the app quickly, press the X button on
popups or use the Escape key (if implemented).
2. Difficulty Selection: Click one of the three colored buttons (Easy,
Medium, Hard).
3. Category Selection: Choose a word theme.
4. Gameplay:
o Type a single letter into the entry box.

o Press Enter on your keyboard or click the "Guess" button.


o Observe the Canvas on the left; the gallows will update

automatically upon incorrect guesses.


5. Winning/Losing: A modal popup will appear at the end of the
session. Click "OK" to reset the board and receive a new word
from the same category.

6. Troubleshooting Common Issues


 "ModuleNotFoundError:No module named 'customtkinter'":

This means Step 2 failed. Re-run the pip install command.


 Emoji Display Issues: If emojis appear as boxes, ensure your OS

is updated or try running the code in a modern terminal like VS


Code's built-in terminal.
 Window Size: If the buttons look too small, the game's dynamic
scaling logic will automatically adjust once you interact with the
window.

40
CONCLUSION

This Hangman game project successfully demonstrates the


practical application of core Python programming concepts
while delivering an engaging user experience. The
implementation showcases effective use of Tkinter and
CustomTkinter for GUI development, random module for game
logic, and structured programming techniques aligned with
CBSE curriculum standards. Through this project, we've
achieved a functional game featuring multiple difficulty levels,
categorized word banks, and real-time visual feedback, all while
maintaining clean code architecture using only standard Python
libraries. The project not only fulfills its educational purpose by
illustrating fundamental programming principles but also
provides a foundation for future enhancements such as
multiplayer functionality or expanded word categories. By
combining technical execution with user-friendly design, this
work serves as both a learning tool and entertaining application,
effectively bridging theoretical computer science concepts with
practical implementation.

41
FURTHER DEVELOPMENT

Although the Hangman game is fully functional, several improvements


can be made to enhance the experience:

Sound Effects: Adding background music and sound effects for correct
and wrong guesses would make the game more interactive and
engaging.

Scoring System: Introducing a score counter based on accuracy and


remaining chances can encourage competition. A high score list can also
be maintained.

Multiplayer Mode: A two-player mode where one enters a word and


the other guesses can make the game more fun.

Hints: A limited hint feature (e.g., revealing one letter) can help players
when they are stuck, especially on harder levels.

Custom Word Input: Allow users to enter their own words or


categories to make the game more personalized.

Countdown Timer: A timer can be added to increase difficulty by


giving players limited time to guess each letter.

Improved Graphics: Replacing simple line drawings with images or


animations can improve the visual appeal of the game.

42
SCREEN LAYOUT
[Link] Screen:
The screen where users can select the difficulty level of the game.

[Link] Screen:
The screen where users can the select the category of the word for
the game.

43
[Link] Screen:
This screen is where the user can play the game. Users can guess the
letters here. If the guessed letter is not in the provided secret word a
part of the hangman appears.

4. Wrong Guess:
When the user guesses the wrong letter a part of the hangman
appears.

44
[Link] Guess:
When the user guesses the correct letter , the letter will appear in its
respective position.

[Link] Lose:
If the hangman gets fully drawn or the Chances left becomes 0 the
user loses the game.

45
6. Game Win:
If the user guesses all the words correctly, the word will get
revealed and he wins the game.

46
BIBLIOGRAPHY

The following resources were referred to during the development of this


project:

1. Sumita Arora ,”Computer Science with Python”,


Textbook for class XII

2. Python Official Documentation


[Link]
(Used to understand Python syntax, functions, and modules)

3. Tkinter GUI Programming Documentation


[Link]
(Used for designing the graphical user interface)

4. GeeksforGeeks
[Link]
(Helped with learning GUI elements and event handling)

5. W3Schools Python Tutorial


[Link]
(Referred for basic Python programming concepts)

47

You might also like