Python Report (1)
Python Report (1)
Project Work
On
“Hangman game”
For the requirement of 1th Semester (4CSPL1011 – Problem Solving Using Python) B.Tech. in
Submitted By
Name USN
ABHISHEK A (24BBTCA006)
ALWIN C S (24BBTCA013)
C GUNASHEKAR (24BBTCA030)
ANANYA L GOWDA ROLL NO-18
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),ROLL NO-18, 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
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()
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 ROCK PAPER SCISSOR GAME
Python is a multipurpose language and one can do anything with it. Python can also be used for game
development. Let’s create a simple command-line Rock-Paper-Scissor game without using any external
game libraries like PyGame. In this game, the user gets the first chance to pick the option between Rock,
paper, and scissors. After the computer select from the remaining two choices(randomly), the winner is
decided as per the rules.
In this game, randint() inbuilt function is used for generating random integer values within the given range.
SOURCE CODE:
11
12
5. OUTPUT
13
6. CONCLUSION
Building a Rock, Paper, Scissors game in Python is a great way to enhance your programming skills while
also having fun. By following the steps outlined in this Python rock, paper, scissors game, you can create
your own game and customize it to your liking. Along the way, you will learn about basic programming
concepts such as functions, loops, and conditional statements. With some creativity and practice, you can
build more complex games using Python. Remember to keep coding and experimenting with new proj ects
to sharpen your skills. Happy coding!
14