lOMoARcPSD|51663645
HANG - hang
Cyber Security (MVJ College of Engineering)
Scan to open on Studocu
Studocu is not sponsored or endorsed by any college or university
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
MINI PROJECT REPORT
ON
“HANGMAN IN PYTHON”
Submitted in partial fulfilment of requirements for the award of 4th Sem degree,
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE & ENGINEERING
Submitted ANANDITA CH 1MJ21CS016 By:
ASHWINI A 1MJ21CS026
D RITHESH 1MJ21CS051
G VEENA 1MJ21CS062
Under the Guidance of
Mr. Kiran Babu T S
Head Of Department, Department of CSE.
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
MVJ COLLEGE OF ENGINEERING
BANGALORE-67
ACADEMIC YEAR 2022-23
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Department of Computer Science and Engineering
Certi昀椀cate
This is to certify that the mini project entitled “HANGMAN IN PYTHON ” is a
Bona-fide work carried out by
1. ANANDITA CH (USN: 1MJ21CS016)
2. ASHWINI A (USN:1MJ21CS026)
3. D RITHESH (USN:1MJ21CS051)
4. G VEENA (USN:1MJ21CS062)
Students of MVJ College of Engineering in partial fulfilment for the award of degree of Bachelor of
Engineering in Computer Science & Engineering of the Visvesvaraya Technological University, Belagavi
during the year 2022-2023. It is certified that all the corrections/suggestions indicated for Internal
assessment have been incorporated in the report. The Mini Project Report has been approved as it satisfies
the academic requirements in respect of Project work prescribed for the said degree.
Signature of the Guide Signature of the Guide Signature of HOD
Internal Signature of the Examiner External
ABSTRACT
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
This is a simple Hangman game using Python programming language. We can use this as a
small project to boost their programming skills and understanding logic. The Hangman program
randomly selects a secret word from a list of secret words. The random module will provide this ability,
to select any word from given list . Hangman is a popular word game in which one player (the "chooser")
chooses a secret word and another player (the "guesser") attempts to guess the word one letter at a
time. If a guessed letter appears in the word, all instances of it are revealed. If not, the guesser
loses a chance. If the guesser figures out the secret word before he or she runs out of chances, he
or she wins. If not, the player who chose the word win.
The project features a well-structured architecture with a clear separation between game logic and the
user interface. It boasts a visually appealing and user-friendly GUI, complete with ASCII art
representations of the hangman figure that dynamically reflect the player's progress. With a meticulous
focus on testing and quality assurance, the Hangman Game Project ensures a smooth and immersive
gaming experience, offering ample room for customization and future enhancements, such as scoring
systems and multiplayer functionality. This project serves as both a valuable educational resource for
developers and an enjoyable game for players of all skill levels, exemplifying the enduring charm of
traditional games brought to life in the digital age.
In conclusion, the Hangman Game Project is a testament to the synergy of programming proficiency and
creative design. It showcases the power of Python and Tkinter in creating an interactive and visually
pleasing game. With its robust codebase, intuitive interface, and potential for expansion, this project
exemplifies the timeless appeal of classic games adapted for modern digital platforms, making it a
rewarding endeavor for both developers and players alike.
ACKNOWLEDGEMENT
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
The satisfaction and euphoria that accompany the successful completion of any task would be
incomplete without the mention of the people who made it possible, whose constant guidance
and encouragement crowned our effort with success.
We express my sincere gratitude to our Principal Dr Suresh babu, & Vice
Principal Mrs. Brindha.M, MVJ College of Engineering for providing facilities.
We wish to place on record our grateful thanks to Dr. Kiran babu T S, Head of the
Department, Computer Science and Engineering, MVJ College of Engineering, Bangalore
for providing encouragement and guidance.
I wish to thank the faculty of Computer Science and Engineering department whose
suggestions have enabled me to surpass many of the seemingly impossible hurdles.
Thank you.
(i)
Table of Contents
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Acknowledgements....................................................................................................................i
1. Introduction.......................................................................................................................7
1.1 Goal.............................................................................................................................7
1.2 Need of the application...............................................................................................7
1.3 Scope...........................................................................................................................8
1.4 Platform Specifications – Deployment........................................................................9
1.4.1 Hardware Specification........................................................................................9
1.4.2 Software Specification.........................................................................................9
2. System Requirement Analysis..........................................................................................9
2.1 Information Gathering..............................................................................................10
2.2 System Feasibility.....................................................................................................10
2.2.1 Economic Feasibility..........................................................................................10
3. System Analysis..............................................................................................................11
3.1 ER Diagram..............................................................................................................12
3.2 Data Flow Diagram...................................................................................................12
3.3 Use case Diagram.....................................................................................................13
3.4 Class Diagram...........................................................................................................14
4. Design.............................................................................................................................14
4.1 Design Goals.............................................................................................................14
4.2Architectural Design..................................................................................................15
4.2.1Architectural Context Diagram...........................................................................16
4.2.2 Description of Architectural Design...................................................................16
4.3 Procedural/Modular Approach..................................................................................16
4.3.1 Shop Products Module.......................................................................................16
4.3.2 Product Description Module..............................................................................16
4.3.3 Cart Details Module...........................................................................................17
5. Implementation...............................................................................................................17
5.1 Database Design and Implementation......................................................................17
5.2 User Interface Design and Implementation..............................................................18
5.3 Technical Discussions...............................................................................................22
6. Testing.............................................................................................................................22
6.1 Unit Testing..............................................................................................................22
6.2 Integration Testing....................................................................................................23
6.3 Source Code..............................................................................................................28
7. Results & Challenges......................................................................................................42
7.1 Challenges.................................................................................................................42
[Link]......................................................................................................................43
8.1 Limitations...............................................................................................................43
8.2 Scope for Future Work...........................................................................................43
8.3 References ..............................................................................................................44
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
TABLE OF FIGURES
3.1 ER DIAGRAM 12
3.2 DATA FLOW DIAGRAM 12
3.3 USE CASE DIAGRAM 13
3.4 CLASS DIAGRAM 14
4.1 ARCHITECTURE DIAGRAM 15
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Hangman in Python 2022-23
1. Introduction
1.1 GOAL
Hangman is a classic word-guessing game where one player thinks of a word and the
other player tries to guess it letter by letter. For each incorrect guess, a part of a hangman
is drawn. The objective is for the guesser to guess the word correctly before the
hangman is fully drawn.
The primary goal of this Python code is to provide an interactive Hangman game that
allows a player to guess a word letter by letter. The game is built using the tkinter library
for the graphical user interface, and it includes features such as displaying Hangman art
to represent incorrect guesses and providing feedback to the player on whether they won
or lost. The code achieves this goal by structuring the program into functions for various
game-related tasks, creating a user-friendly GUI, and implementing the core logic of the
Hangman game.
Overall, this code serves as a fun and educational example of how to create a simple
game using Python and tkinter. It demonstrates concepts such as user interface design,
event handling, game state management, and ASCII art rendering. Players can enjoy the
challenge of guessing words while avoiding the drawing of the Hangman figure.
1.2 Objective of Hangman game
The objective of the provided Python project is to create an interactive Hangman game
with a graphical user interface using the tkinter library. This project serves both
educational and recreational purposes. Below are the primary objectives of this project:
Game Development Learning: This project serves as a practical exercise for
individuals learning Python programming and game development concepts. It
demonstrates how to create a simple text-based game and integrate it with a
graphical user interface.
Graphical User Interface (GUI) Application: The project aims to showcase how
to build a GUI application using the tkinter library. It provides hands-on
experience in designing and implementing a user-friendly interface for a game.
Hangman Gameplay: The primary objective of the project is to implement the
classic Hangman gameplay. Users can play the game by guessing letters to
uncover a hidden word. The project aims to offer an enjoyable and engaging
gaming experience.
Interactive Features: The project incorporates interactive elements, such as text
input for letter guesses and a button to submit guesses. This adds an element of
user engagement and interactivity to the game.
Feedback and Visuals: The game provides immediate feedback to the player
about the correctness of their guesses. It also uses ASCII art to visually represent
the progress of the game, adding an element of visual storytelling.
4th SEM DEPT OF CSE, MVJCE 7
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Hangman in Python 2022-23
Random Word Selection: The project includes the functionality to randomly
select a word from a predefined list of words. This adds an element of
randomness to the game, ensuring that each playthrough is different.
Win/Lose Conditions: The game includes win and lose conditions. If the player
correctly guesses all the letters in the word before making too many incorrect
guesses, they win. If they exceed the maximum number of incorrect guesses,
they lose.
Educational Value: While providing entertainment, the project has educational
value. It encourages players to expand their vocabulary as they guess words and
letters. It also teaches programming concepts related to GUI development, event
handling, and game logic.
Code Structure and Modularization: The project demonstrates good coding
practices by organizing code into functions. This modular approach makes the
code more readable, maintainable, and extensible.
Application of Python Libraries: The project showcases the use of Python
libraries such as tkinter for creating a GUI and random for random word
selection. It highlights how Python can be used for various real-world
applications beyond text-based programs.
User Experience: The project aims to provide an enjoyable and intuitive user
experience by presenting the game in a visually appealing and interactive format.
1.3 Conclusion of Introduction
The Hangman game project successfully combines educational and recreational
elements. It provides a platform for Python learners to practice programming concepts,
especially in GUI development, while offering an engaging and interactive gaming
experience. The project's graphical user interface, powered by the tkinter library, allows
players to guess letters and receive immediate feedback through Hangman ASCII art and
word blanks. With win and lose conditions, random word selection, and well-organized,
modular code, the project serves as a valuable example of how Python can be applied to
create user-friendly applications beyond the command line. It promotes both learning
and enjoyment, making it a versatile and educational resource for a wide range of users.
In conclusion, the Hangman game project excels in delivering an educational and
entertaining experience. Its incorporation of GUI elements, gameplay features, and
Python library usage showcases the practicality and versatility of Python programming.
Whether for programming enthusiasts looking to hone their skills or individuals seeking
a fun word-guessing challenge, the Hangman game project offers an accessible and
engaging solution.
4th SEM DEPT OF CSE, MVJCE 8
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Hangman in Python 2022-23
[Link] programming concepts
The Hangman game project involves several fundamental programming concepts and
techniques. Here are the basic concepts used in coding the project:
Data Structures:
Lists: The project uses lists to store words that can be chosen as the target word for the game.
Lists are also used to store Hangman ASCII art representations in different stages.
Functions:
Function Definitions: Functions are defined to encapsulate specific tasks, such as choosing a
word, updating Hangman art, checking guesses, and ending the game. This modular approach
enhances code organization and reusability.
Conditional Statements:
If Statements: Conditional statements (if, elif, and else) are used to check whether a guessed
letter is correct and to determine the game's outcome (win or lose).
Loops:
For Loop: A for loop is used to iterate through the characters of the word to check if a guessed
letter is present.
User Input:
Entry Widget: The tkinter Entry widget is employed to collect user input, specifically the
guessed letter.
GUI Development:
tkinter Library: The project demonstrates GUI development using the tkinter library. It creates
windows, labels, buttons, and entry fields to create an interactive user interface.
Event Handling:
Button Click Event: The tkinter button is configured with a command that specifies the function
to be called when the button is clicked. This demonstrates event-driven programming.
Randomization:
Random Module: The random module is used to select a random word from the list of words,
providing variety in the gameplay.
String Manipulation:
String Slicing and Concatenation: String manipulation techniques are used to create and update
the word with blanks as the player makes correct guesses.
4th SEM DEPT OF CSE, MVJCE 9
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Hangman in Python 2022-23
Global and Local Variables:
Global Variables: Global variables are used to keep track of game-related information, such as
the chosen word and the number of mistakes.
Local Variables: Local variables are employed within functions to store temporary data.
Feedback and Output:
Label Widgets: tkinter Label widgets are used to display Hangman ASCII art, the word with
blanks, and the game result to the user.
Control Flow:
Game Flow Control: The code controls the flow of the game, transitioning from one stage to
another based on user input and game conditions.
Modularization and Code Organization:
Function Modularity: The code is organized into functions, each responsible for a specific aspect
of the game. This modular structure enhances code readability and maintainability.
Conditional Logic:
Game Logic: The code implements the core logic of the Hangman game, including checking
guesses, updating the Hangman art, and determining win or lose conditions.
User Experience:
Visual Feedback: The project provides visual feedback to the user through Hangman art,
enhancing the overall user experience.
These fundamental programming concepts and techniques are essential building blocks for
creating a functional Hangman game with a graphical user interface. They demonstrate how to
apply programming knowledge to develop an interactive and engaging application.
2.1 TKINTER LIBRARY
Tkinter is a Python library used for creating graphical user interfaces (GUIs). It provides a set of
tools and widgets for building windows, dialogs, buttons, textboxes, and other graphical
elements that enable users to interact with your Python applications in a visual way. Tkinter is
often referred to as the standard GUI library for Python due to its simplicity, ease of use, and
widespread availability.
Here is an introduction to key aspects of Tkinter:
Cross-Platform Compatibility: Tkinter is cross-platform and comes pre-installed with
most Python distributions, making it accessible on Windows, macOS, and Linux. This
allows developers to create GUI applications that work consistently across different
operating systems.
4th SEM DEPT OF CSE, MVJCE 10
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Hangman in Python 2022-23
Widgets: Tkinter provides a wide range of built-in widgets (also known as GUI
elements) that can be placed in your application's windows. Some common widgets
include:
Labels: Used to display text or images.
Buttons: Used to trigger actions when clicked.
Entry Widgets: For user input of single-line text.
Text Widgets: For multi-line text input or display.
Canvas: A drawing area for custom graphics.
Listboxes: To display lists of items.
Checkbuttons and Radiobuttons: For binary and mutually exclusive choices.
: For creating dropdown menus.
Event-Driven Programming: Tkinter follows an event-driven programming model. It
means that your program responds to events such as button clicks, mouse movements, or
keyboard inputs. You define event handlers (functions) that execute when specific events
occur.
Geometry Management: Tkinter includes geometry managers that help you arrange
widgets within windows. The three main geometry managers are pack, grid, and place.
They allow you to control the layout and positioning of widgets.
Main Event Loop: Tkinter applications run in an event-driven loop, known as the main
event loop. This loop constantly checks for user actions and responds to events like
button clicks or keyboard inputs. The main event loop keeps your GUI responsive and
interactive.
Customization: Tkinter allows you to customize the appearance of widgets, including
fonts, colors, and styles, to create visually appealing interfaces that match your
application's design.
Dialogs: Tkinter provides common dialogs for tasks such as opening and saving files,
selecting colors, and displaying messages. These dialogs simplify user interactions with
your application.
Integration with Python: Tkinter seamlessly integrates with Python, making it easy to
combine the power of Python with the visual capabilities of a GUI. You can use Python's
data manipulation capabilities and libraries in your GUI applications.
Community Support: Tkinter has a robust community of users and developers who share
resources, tutorials, and code examples. This makes it easier to find help and solutions to
common issues.
Extensibility: While Tkinter offers a rich set of built-in widgets and features, you can
extend its functionality by using third-party libraries like ttk (themed Tkinter) for
modern, themed widgets or other GUI libraries if needed.
4th SEM DEPT OF CSE, MVJCE 11
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Hangman in Python 2022-23
In summary, Tkinter is a powerful and accessible library for creating GUI applications in
Python. Whether you're building simple utilities, interactive applications, or data
visualization tools, Tkinter's ease of use and cross-platform compatibility make it an
excellent choice for developers looking to add a graphical interface to their Python
programs
2.3 ADVANTAGES OF HANGMAN
The Hangman game, implemented using the Tkinter library in Python, offers several advantages
to outside users, including players and learners. Here are some of the key benefits:
Entertainment and Recreation: The Hangman game provides an enjoyable and
challenging word-guessing experience. It serves as a source of entertainment and
recreation, making it an engaging pastime for users of all ages.
Vocabulary Enhancement: Users can improve their vocabulary and language skills by
guessing words and letters in the game. It encourages word exploration and learning,
making it an educational tool for language development.
Interactive Learning: The game's graphical user interface (GUI) and interactive features,
such as letter input and feedback, create an engaging learning environment. It offers an
interactive way for users to practice spelling and word recognition.
Cross-Platform Compatibility: The game is built using Tkinter, which is cross-platform
and works on various operating systems. Users can enjoy the game on Windows, macOS,
and Linux without compatibility issues.
User-Friendly Interface: The Tkinter-based GUI provides a user-friendly and intuitive
interface. It simplifies the gameplay experience, allowing users to focus on the game
itself rather than technical complexities.
Visual Feedback: The game offers visual feedback through Hangman ASCII art and
word blanks, enhancing the player's experience. The evolving Hangman figure adds a
visual storytelling element to the game.
Randomized Gameplay: The game's random word selection ensures that each
playthrough is unique. This variety keeps the game fresh and prevents predictability,
encouraging repeated play.
Problem-Solving Skills: Players can enhance their problem-solving skills by strategically
guessing letters and trying to uncover the hidden word. It encourages critical thinking
and deduction.
Simple and Accessible: The Hangman game is designed to be simple and accessible to a
wide range of users. Its straightforward rules and familiar gameplay make it
approachable for both beginners and experienced gamers.
Community and Resources: The Hangman game project is part of a thriving community
of Python enthusiasts and learners. Users can access resources, tutorials, and support
from the Python community to enhance their gaming experience or programming
knowledge.
Customization and Extensibility: Users can customize and extend the game by modifying
the code. This allows for personalization and the addition of new features or themes,
providing a creative outlet for users interested in game development.
4th SEM DEPT OF CSE, MVJCE 12
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Hangman in Python 2022-23
[Link] Details
The Hangman game implementation using Tkinter in Python involves creating a
graphical user interface (GUI) for the game and implementing the game logic. Below are
the key implementation details of the code:
1. Importing Libraries:
The code begins by importing the necessary libraries: tkinter for creating the GUI and
random for selecting random words.
**********
2. Defining Game Data:
The code defines two important data structures: words and hangman_art.
words is a list containing words that can be chosen as the target word for the game.
hangman_art is a list of ASCII art representations of the Hangman figure in different
stages.
************
3. Game Functions:
Several functions are defined to handle various aspects of the game.
choose_word(): Selects a random word from the words list to be guessed.
update_hangman(mistakes): Updates the Hangman ASCII art displayed in the GUI based
on the number of mistakes.
check_guess(): Checks if the guessed letter is in the target word and updates the game
accordingly.
end_game(result): Ends the game and displays the result (win or lose) in the GUI.
*********
4. Creating the Tkinter Window:
The code initializes the main tkinter window (root) and sets its title to "HANGMAN."
5. GUI Elements:
The code creates and configures various GUI elements (widgets) such as labels, entry
fields, and buttons. These elements are placed within specific rows and columns using
the grid method.
****************
6. Initializing the Game:
The code initializes the game by choosing a random word from the words list, creating a
string of underscores to represent the word with blanks, and displaying the initial
Hangman ASCII art in the GUI.
**************
7. Main Event Loop:
The tkinter main event loop ([Link]()) is started, which keeps the GUI running
and responsive to user interactions.
**************
4th SEM DEPT OF CSE, MVJCE 13
Downloaded by mukul mishra ([Link]@[Link])
lOMoARcPSD|51663645
Hangman in Python 2022-23
These implementation details illustrate how the Hangman game code using Tkinter
combines game logic, GUI development, and interactive elements to create an enjoyable
gaming experience. Users can interact with the GUI by guessing letters and receive
immediate feedback on their progress through the Hangman ASCII art and word blanks.
The game continues until the user either correctly guesses the word or makes too many
incorrect guesses, resulting in a win or lose condition. The code's modular structure and
integration with Python libraries make it a practical and educational resource for both
game enthusiasts and learners.
4th SEM DEPT OF CSE, MVJCE 14
Downloaded by mukul mishra ([Link]@[Link])