Python Report (2)
Python Report (2)
Project Work
On
“Hangman game”
For the requirement of 1 th Semester (4CSPL1011 – Problem Solving Using Python) B.Tech. in
Submitted By
Name USN
ABHISHEK A (24BBTCA006)
ALWIN C S (24BBTCA013)
C GUNASHEKAR (24BBTCA030)
BN BHARATH TEJA ROLL NO-27
Submitted to
CMR University
Off Hennur - Bagalur Main Road, Near Kempegowda International Airport, Chagalahatti, Bengaluru,
Karnataka-562149 Academic Year - 2024-25
1
SCHOOL OF ENGINEERING AND TECHNOLOGY
Chagalahatti, Bengaluru, Karnataka-562149
CERTIFICATE
Certified that the Project Work entitled “Hangman game” carried out by (24BBTCA006),
(24BBTCA013),(24BBTCA030), and ROLL NO-27 Bonafide students
of SCHOOL OF ENGINEERING AND TECHNOLGY, in
partial fulfillment for the award of BACHELOR OF TECHNOLOGY in 1th Semester
Computer Science and Engineering of CMR UNIVERSITY, Bengaluru during the year
2025. It is certified that all corrections/suggestions indicated for the Internal
Assessment have been incorporated in the report. The project has been approved as it satisfies
the academic requirements in respect of project work prescribed for the said degree.
2
Abstract:
The purpose of this project is to create a simple Python program that implements the classic Hangman game. Hangman is a
word-guessing game where players attempt to identify a hidden word by guessing letters within a limited number of attempts.
This report describes the program's design, functionality, and implementation, providing an engaging and interactive
experience for users.
3
SR . NO TOPIC PAGE . NO
1 Python 5
2 Tkinter Programming 7
4 Source Code 11
5 Output 13
6 Conclusion 14
4
1. PYTHON
History of Python
Python was developed by Guido van Rossum in the late eighties and early nineties at the
National Research Institute for Mathematics and Computer Science in the Netherlands.
Python is derived from many other languages, including ABC, Modula-3, C, C++,
Algol68, SmallTalk, and Unix shell and other scripting languages.
Python is copyrighted. Like Perl, Python source code is now available under the GNU
General Public License (GPL).
Python is now maintained by a core development team at the institute, although Guido
van Rossum still holds a vital role in directing its progress.
Python Features
6
2. Tkinter Programming
Tkinter is the standard GUI library for Python. Python when combined with Tkinter
provides a fast and easy way to create GUI applications. Tkinter provides a powerful
object-oriented interface to the Tk GUI toolkit.
Creating a GUI application using Tkinter is an easy task. All you need to do is perform
the following steps −
• Import the Tkinter module.
Enter the main event loop to take action against each event triggered by the user.
Example
#!/usr/bin/python3
import tkinter as tk
top = tk.Tk()
# Code to add widgets will go here...
top.mainloop()
Tkinter Widgets
Tkinter provides various controls, such as buttons, labels and text boxes used in a GUI
application. These controls are commonly called widgets.
There are currently 15 types of widgets in Tkinter. We present these widgets as well as a brief
description in the following table –
7
Sr.No. Operator & Description
1
Button
2
Canvas
The Canvas widget is used to draw shapes, such as lines, ovals, polygons and rectangles, in
your application.
3
Checkbutton
The Checkbutton widget is used to display a number of options as checkboxes. The user can
select multiple options at a time.
4
Entry
The Entry widget is used to display a single-line text field for accepting values from a user.
5
Frame
6
Label
The Label widget is used to provide a single-line caption for other widgets. It can also contain
images.
7
Listbox
8
Menubutton
9
Menu
The Menu widget is used to provide various commands to a user. These commands are
contained inside Menubutton.
10
Message
The Message widget is used to display multiline text fields for accepting values from a user.
8
11
Radiobutton
The Radiobutton widget is used to display a number of options as radio buttons. The user can
select only one option at a time.
12
Scale
13 Scrollbar
The Scrollbar widget is used to add scrolling capability to various widgets, such as list boxes.
14
Text
15
Toplevel
16
Spinbox
The Spinbox widget is a variant of the standard Tkinter Entry widget, which can be used to select
from a fixed number of values.
17
PanedWindow
A PanedWindow is a container widget that may contain any number of panes, arranged
horizontally or vertically.
18
LabelFrame
A labelframe is a simple container widget. Its primary purpose is to act as a spacer or container
for complex window layouts.
19
tkMessageBox
9
3. VISUAL STUDIO CODE
Visual Studio Code is a free source code editor, made by Microsoft for Windows,
Linux and macOS. Features include support for debugging, syntax highlighting,
intelligent code completion, snippets, code refactoring, and embedded Git. Users can
change the theme, keyboard shortcuts, preferences, and install extensions that add
additional functionality. The python extension in Visual Studio Code makes it an
excellent video editor.
10
4. PYTHON PROGRAM TO IMPLEMENT HANGMAN GAME
The origins of Hangman are obscure meaning not discovered, but it seems to have arisen in Victorian times, ”
says Tony Augarde, author of The Oxford Guide to Word Games. The game is mentioned in Alice Bertha
Gomme’s “Traditional Games” in 1894 under the name “Birds, Beasts and Fishes.” The rules are simple; a
player writes down the first and last letters of a word and another player guesses the letters in between. In other
sources, [where?] the game is called “Gallows”, “The Game of Hangin”, or “Hanger”.
This is a simple Hangman game using Python programming language. Beginners can use this as a small project
to boost their programming skills and understanding logic.
1. The Hangman program randomly selects a secret word from a list of secret words. The random module
will provide this ability, so line 1 in program imports it.
2. The Game: Here, a random word (a fruit name) is picked up from our collection and the player gets
limited chances to win the game.
3. When a letter in that word is guessed correctly, that letter position in the word is made visible. In this
way, all letters of the word are to be guessed before all the chances are over.
4. For convenience, we have given length of word + 2 chances. For example, word to be guessed is mango,
then user gets 5 + 2 = 7 chances, as mango is a five-letter word.
SOURCE CODE:
11
12
5. OUTPUT
13
6. CONCLUSION
The Hangman Python project successfully replicates the classic word-guessing game in a digital format,
showcasing the practical application of fundamental programming concepts such as loops, conditionals,
string manipulation, and user interaction. Through this project, users can enjoy an interactive and
engaging experience, reinforcing the importance of logical thinking and problem-solving.
This project highlights the versatility of Python in developing small-scale games and provides a
foundation for further improvements, such as adding a graphical user interface, multiplayer functionality,
or a larger word database. Overall, the Hangman program demonstrates how simple coding projects can
be both educational and entertaining.
14