0% found this document useful (0 votes)
9 views

Python Report (2)

The document outlines a project report for a Hangman game developed in Python as part of a B.Tech curriculum at CMR University. It includes details on the game's design, implementation, and the educational value of the project, emphasizing programming concepts like loops and user interaction. The report also discusses the use of Python and Tkinter for GUI development, and concludes with suggestions for future enhancements.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python Report (2)

The document outlines a project report for a Hangman game developed in Python as part of a B.Tech curriculum at CMR University. It includes details on the game's design, implementation, and the educational value of the project, emphasizing programming concepts like loops and user interaction. The report also discusses the use of Python and Tkinter for GUI development, and concludes with suggestions for future enhancements.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

SCHOOL OF ENGINEERING AND TECHNOLOGY

Project Work
On

“Hangman game”

For the requirement of 1 th Semester (4CSPL1011 – Problem Solving Using Python) B.Tech. in

Computer Science and Engineering - AIML

Submitted By

Name USN
ABHISHEK A (24BBTCA006)
ALWIN C S (24BBTCA013)
C GUNASHEKAR (24BBTCA030)
BN BHARATH TEJA ROLL NO-27

Submitted to

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING - AIML

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

Department of Computer Science and Engineering - AIML

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.

Course in charge H.O. D

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

3 Visual studio code 10

4 Source Code 11

5 Output 13

6 Conclusion 14

4
1. PYTHON

Python is a high-level, interpreted, interactive and object-oriented scripting language.


Python is designed to be highly readable. It uses English keywords frequently where as
other languages use punctuation, and it has fewer syntactical constructions than other
languages.
• Python is Interpreted − Python is processed at runtime by the interpreter. You do
not need to compile your program before executing it. This is similar to PERL and
PHP. Python is Interactive − You can actually sit at a Python prompt and interact
with the interpreter directly to write your programs.
• Python is Object-Oriented − Python supports Object-Oriented style or technique
of programming that encapsulates code within objects.
• Python is a Beginner's Language − Python is a great language for the
beginnerlevel programmers and supports the development of a wide range of
applications from simple text processing to WWW browsers to games.

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

Python's features include −


• Easy-to-learn − Python has few keywords, simple structure, and a clearly defined
syntax. This allows the student to pick up the language quickly.
• Easy-to-read − Python code is more clearly defined and visible to the eyes.
• Easy-to-maintain − Python's source code is fairly easy-to- maintain.
• A broad standard library − Python's bulk of the library is very portable and
crossplatform compatible on UNIX, Windows, and Macintosh.
• Interactive Mode − Python has support for an interactive mode which allows
interactive testing and debugging of snippets of code.
• Portable − Python can run on a wide variety of hardware platforms and has the
same interface on all platforms.
• Extendable − You can add low-level modules to the Python interpreter. These
modules enable programmers to add to or customize their tools to be more efficient.
5
• Databases − Python provides interfaces to all major commercial databases.
• GUI Programming − Python supports GUI applications that can be created and
ported to many system calls, libraries and windows systems, such as Windows
MFC, Macintosh, and the X Window system of Unix.
• Scalable − Python provides a better structure and support for large programs than
shell scripting.
Apart from the above-mentioned features, Python has a big list of good features, few are
listed below −
• It supports functional and structured programming methods as well as OOP.
• It can be used as a scripting language or can be compiled to byte- code for building
large applications.
• It provides very high-level dynamic data types and supports dynamic type
checking.
• It supports automatic garbage collection.
• It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

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.

• Create the GUI application main window.


• Add one or more of the above-mentioned widgets to the GUI application. •

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()

This would create a following window −

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

The Button widget is used to display buttons in your application.

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

The Frame widget is used as a container widget to organize other widgets.

6
Label
The Label widget is used to provide a single-line caption for other widgets. It can also contain
images.

7
Listbox

The Listbox widget is used to provide a list of options to a user.

8
Menubutton

The Menubutton widget is used to display menus in your application.

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

The Scale widget is used to provide a slider widget.

13 Scrollbar

The Scrollbar widget is used to add scrolling capability to various widgets, such as list boxes.

14
Text

The Text widget is used to display text in multiple lines.

15
Toplevel

The Toplevel widget is used to provide a separate window container.

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

This module is used to display message boxes in your applications.

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.

Fig1: Visual Studio Code Platform

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

You might also like