HANGMAN GAME
Application Development Lab Report Submitted
In partial fulfillment of the requirements for the award of the degree of
Bachelor of Technology
in
Computer Science and Engineering
by
R. NANDAN REDDY 20N31A0560
N. ANSHITH VARMA 20N31A0519
Under the esteemed guidance of
B Saritha
Assistant Professor
Department of Computer Science and Engineering
Malla Reddy College of Engineering & Technology
(Autonomous Institution- UGC, Govt. of India)
(Affiliated to JNTUH, Hyderabad, Approved by AICTE, NBA &NAAC with ‘A’ Grade)
Maisammaguda, Kompally, Dhulapally, Secunderabad – 500100
website: [Link]
2020-2024
1
Malla Reddy College of Engineering & Technology
(Autonomous Institution- UGC, Govt. of India)
(Affiliated to JNTUH, Hyderabad, Approved by AICTE, NBA &NAAC with ‘A’ Grade)
Maisammaguda, Kompally, Dhulapally, Secunderabad – 500100
website: [Link]
CERTIFICATE
This is to certify that this is the bonafide record of the project entitled “HANGMAN GAME”,
submitted by R. Nandan Reddy (20N31A0560) and N. Anshith Varma (20N31A0519) of [Link] in
the partial fulfillment of the requirements for the degree of Bachelor of Technology in
Computer Science and Engineering, Department of CSE during the year 2022-2023. The results
embodied in this project report have not been submitted to any other university or institute for
the award of any degree or diploma.
Internal Guide Head of the Department
B Saritha Dr. S. Shanthi
Assistant professor Professor
External Examiner
2
DECLARATION
We hereby declare that the project titled “REAL TIME FACE BLUR” submitted to Malla Reddy
College of Engineering and Technology (UGC Autonomous), affiliated to Jawaharlal Nehru
Technological University Hyderabad (JNTUH) for the award of the degree of Bachelor of
Technology in Computer Science and Engineering is a result of original research carried-out in
this thesis. It is further declared that the project report or any part thereof has not been
previously submitted to any University or Institute for the award of degree or diploma.
Anshith Varma-(20N31A0519)
Nandan Reddy - (20N31A0560)
3
ACKNOWLEDGEMENT
Acknowledgements are to be written by the students as per the sequence mentioned below
1) Principal
2) Head of the Department
3) Project Coordinator
4) Internal Guide
5) Parents and other people who helped to complete the project
with regards and gratitude
Anshith Varma-(20N31A0519)
Nandan Reddy - (20N31A0560)
4
ABSTRACT
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, so line 1 in program imports it. 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 wins.
5
TABLE OF CONTENTS
TOPIC PAGE NO
1. INTRODUCTION
1.1 Python Programming Language 7
1.2 Applications of Python 9
1.3 About Hangman game 10
2. SYSTEM REQUIREMENTS
2.1 Software Requirements 11
2.2 Hardware Requirements 11
3. IMPLEMENTATION AND RESULTS
3.1 About project 12
3.2 Project Code 13
3.3. Results 16
3.4 System architecture 18
3.5 UML diagrams 19
CONCLUSION 21
6
INTRODUCTION
1.1. Python Programming language
Python is one of the many open source object oriented programming application software
available in the market . Python is developed by Guido van Rossum. Guido van Rossum
started implementing Python in 1989. Python is a very simple programming language so even
if you are new to programming, you can learn python without facing any issues. Some of the
many uses of Python are application development, implementation of automation testing
process, allows multiple programming build, fully constructed programming library, can be
used in all the major operating systems and platforms, database system accessibility, simple
and readable code, easy to apply on complex software development processes, aids in test
driven software application development approach, machine learning/ data analytics, helps
pattern recognitions, supported in multiple tools, permitted by many of the provisioned
frameworks, etc.
Some features of Python are-
7
1. Readable: Python is a very readable language.
2. Easy to Learn: Learning python is easy as this is a expressive and high level programming
language, which means it is easy to understand the language and thus easy to learn.
3. Cross platform: Python is available and can run on various operating systems such as Mac,
Windows, Linux, Unix etc. This makes it a cross platform and portable language.
4. Open Source: Python is a open source programming language.
5. Large standard library: Python comes with a large standard library that has some handy codes
and functions which we can use while writing code in Python.
6. Free: Python is free to download and use. This means you can download it for free and use it in
your application. See: Open Source Python License. Python is an example of a FLOSS (Free/Libre
Open Source Software), which means you can freely distribute copies of this software, read its source
code and modify it.
7. Supports exception handling: If you are new, you may wonder what is an exception? An
exception is an event that can occur during program exception and can disrupt the normal flow of
program. Python supports exception handling which means we can write less error prone code and can
test various scenarios that can cause an exception later on.
8. Advanced features: Supports generators and list comprehensions. We will cover these features
later.
9. Automatic memory management: Python supports automatic memory management which means
the memory is cleared and freed automatically
8
1.2. Applications of Python programming language
Python can be used to develop different applications like web applications, graphic user interface
based applications, software development application, scientific and numeric applications, network
programming, Games and 3D applications and other business applications. It makes an interactive
interface and easy development of [Link] may be wondering what all are the applications of
Python. There are so many applications of Python, here are some of the them.
1. Web development – Web framework like Django and Flask are based on Python. They help you
write server side code which helps you manage database, write backend programming logic, mapping
urls etc.
2. Machine learning – There are many machine learning applications written in Python. Machine
learning is a way to write a logic so that a machine can learn and solve a particular problem on its
own. For example, products recommendation in websites like Amazon, Flipkart, eBay etc. is a
machine learning algorithm that recognises user’s interest. Face recognition and Voice recognition in
your phone is another example of machine learning.
3. Data Analysis – Data analysis and data visualisation in form of charts can also be developed using
Python.
4. Scripting – Scripting is writing small programs to automate simple tasks such as sending automated
response emails etc. Such type of applications can also be written in Python programming language.
5. Game development – You can develop games using Python.
6. You can develop Embedded applications in Python.
7. Desktop applications – You can develop desktop application in Python using library like TKinter or
QT.
9
1.3. About Hangman game
The Hangman Game In Python is written in a python programming language, In this Hangman Game
Project is to implement the Hangman Game Using Python.
A Hangman Game On Python is about guessing letters (A-Z) to form the words. If the player guesses
the right letter that is within the word, the letter appears at its correct position. The user has to guess the
correct word until a man is hung, then the game is over.
The word to guess is represented by a row of dashes representing each letter of the word. Rules may
permit or forbid proper nouns, such as names, places, brands, or slang. If the guessing player suggests a
letter which occurs in the word, the other player writes it in all its correct positions. If the suggested letter
does not occur in the word, the other player removes (or alternatively, adds) one element of a
hanged stick figure as a tally mark. Generally, the game ends once the word is guessed, or if the stick
figure is complete — signifying that all guesses have been used.
The player guessing the word may, at any time, attempt to guess the whole word. If the word is correct,
the game is over and the guesser wins. Otherwise, the other player may choose to penalize the guesser by
adding an element to the diagram. On the other hand, if the guesser makes enough incorrect guesses to
allow the other player to complete the diagram, the guesser loses. However, the guesser can also win by
guessing all the letters that appear in the word, thereby completing the word, before the diagram is
completed.
10
SYSTEM REQUIREMENTS
2.1 Software Requirements
PyCharm2019.1.1(CommunityEdition)
Build#PC-191.6605.12,built on April 3, 2019
JRE:11.0.2+9-b159.34amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
2.2 Hardware Requirements
Operating system: windows 10
Processor: intel core i5
Disk space:1Gb
11
IMPLEMENTATION AND RESULTS
3.1 About Project
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.
12
3.2 Project code
import random
import time
# Initial Steps to invite in the game:
print("\nWelcome to Hangman game by IT SOURCECODE\n")
name = input("Enter your name: ")
print("Hello " + name + "! Best of Luck!")
[Link](2)
print("The game is about to start!\n Let's play Hangman!")
[Link](3)
# The parameters we require to execute the game:
def main():
global count
global display
global word
global already_guessed
global length
global play_game
words_to_guess =
["january","border","image","film","promise","kids","lungs","doll","rhyme","
damage"
,"plants"]
word = [Link](words_to_guess)
length = len(word)
count = 0
display = '_' * length
already_guessed = []
play_game = ""
# A loop to re-execute the game when the first round ends:
def play_loop():
global play_game
play_game = input("Do You want to play again? y = yes, n = no \n")
while play_game not in ["y", "n","Y","N"]:
play_game = input("Do You want to play again? y = yes, n = no \n")
if play_game == "y":
main()
elif play_game == "n":
print("Thanks For Playing! We expect you back again!")
exit()
# Initializing all the conditions required for the game:
def hangman():
global count
13
global display
global word
global already_guessed
global play_game
limit = 5
guess = input("This is the Hangman Word: " + display + " Enter your
guess: \n")
guess = [Link]()
if len([Link]()) == 0 or len([Link]()) >= 2 or guess <= "9":
print("Invalid Input, Try a letter\n")
hangman()
elif guess in word:
already_guessed.extend([guess])
index = [Link](guess)
word = word[:index] + "_" + word[index + 1:]
display = display[:index] + guess + display[index + 1:]
print(display + "\n")
elif guess in already_guessed:
print("Try another letter.\n")
else:
count += 1
if count == 1:
[Link](1)
print(" ___ \n"
" | \n"
" | \n"
" | \n"
" | \n"
" | \n"
" | \n"
"_|_\n")
print("Wrong guess. " + str(limit - count) + " guesses
remaining\n")
elif count == 2:
[Link](1)
print(" ___ \n"
" | | \n"
" | |\n"
" | \n"
" | \n"
" | \n"
" | \n"
"_|_\n")
print("Wrong guess. " + str(limit - count) + " guesses
remaining\n")
elif count == 3:
[Link](1)
14
print(" ___ \n"
" | | \n"
" | |\n"
" | | \n"
" | \n"
" | \n"
" | \n"
"_|_\n")
print("Wrong guess. " + str(limit - count) + " guesses remaining\
n")
elif count == 4:
[Link](1)
print(" ___ \n"
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | \n"
" | \n"
"_|_\n")
print("Wrong guess. " + str(limit - count) + " last guess
remaining\n")
elif count == 5:
[Link](1)
print(" ___ \n"
" | | \n"
" | |\n"
" | | \n"
" | O \n"
" | /|\ \n"
" | / \ \n"
"_|_\n")
print("Wrong guess. You are hanged!!!\n")
print("The word was:",already_guessed,word)
play_loop()
if word == '_' * length:
print("Congrats! You have guessed the word correctly!")
play_loop()
elif count != limit:
hangman()
main()
hangman()
15
3.3 Results
Snapshots taken from successful runs of the project
Snapshot 3.1:output screen
Snapshot 3.2:output screen(true case)
16
Snapshot 3.3:output screen
Snapshot 3.4:output screen(false case)
17
3.4 System architecture
18
3.5 UML DIAGRAMS
ACTIVITY DIAGRAM
19
USE CASE DIAGRAM
20
CONCLUSION
In the conclusion of this project, Hangman is a traditional game, typically played with words. It’s
possible, however, to play Category Hangman rather than guessing words the player might guess
names of cities, or athletes, or fictional characters, or Duke professors, or top forty song titles the list is
endless. You’ll be writing a program to play a “guess a word letter-by-letter” version of hangman as
shown above. You’ll also be doing some statistical analysis of the words used in the Hangman game.
21