Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

VERBALIZE - A HANGMAN GAME

A Project Report submitted in partial fulfilment of the requirements for


the award of the degree of

BACHELOR OF TECHNOLOGY

IN

COMPUTER SCIENCE AND ENGINEERING

Submitted by

K. SIVA LAKSHMI POOJITHA 222010312035


C. VEDA PRIYA 222010312042
K. ONIKA SRI HARSHINI 222010312052
N. SREE NITHYA 222010312057

Under the Guidance of


Dr. Ravi Teja Bhima
Assistant Professor

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

GITAM (Deemed to be University)

HYDERABAD

APRIL – 2024

1
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
GITAM SCHOOL OF TECHNOLOGY

GITAM (Deemed to be University)

DECLARATION

I/We, hereby declare that the project report entitled “VERBALIZE – A HANGMAN GAME” is an
original work done in the Department of Computer Science and Engineering, GITAM School of
Technology, GITAM (Deemed to be University) submitted in partial fulfilment of the requirements for the
award of the degree of B.Tech. in Computer Science and Engineering. The work has not been submitted to
any other college or University for the award of any degree or diploma.

Date: 26-Feb-24

Registration No(s). Name(s) Signature(s)

222010312035 K. Siva Lakshmi Poojitha


222010312042 C. Veda Priya
222010312052 K. Onika Sri Harshini
222010312057 N. Sree Nithya

2
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
GITAM SCHOOL OF TECHNOLOGY

GITAM (Deemed to be University)

CERTIFICATE

This is to certify that the project report entitled “VERBALIZE – A HANGMAN GAME” is a Bonafide
record of work carried out by K. SIVA LAKSHMI POOJITHA – 222010312035 C. VEDA PRIYA –
222010312042, K. ONIKA SRI HARSHINI – 222010312052, N. SREE NITHYA - 222010312057
students submitted in partial fulfilment of requirement for the award of degree of Bachelors of Technology
in Computer Science and Engineering.

Project Guide Project Coordinator Head of the Department

Dr. Ravi Teja Bhima Dr. S. Aparna Mahaboob Basha Shaik


Assistant Professor Assistant Professor Professor & HOD
Dept. of CSE Dept. of CSE Dept. of CSE

3
ACKNOWLEDGEMENT

Our project report would not have been successful without the help of several people. We would like to
thank the personalities who were part of our seminar in numerous ways, those who gave us outstanding
support from the birth of the seminar.

We are extremely thankful to our honourable Pro-Vice-Chancellor, Prof. D. Sambasiva Rao, for providing
the necessary infrastructure and resources for the accomplishment of our seminar. We are highly indebted to
Prof. N. Seetha Ramaiah, Associate Director, School of Technology, for his support during the tenure of
the seminar.

We are very much obliged to our beloved Prof. Mahaboob Basha Shaik, Head of the Department of
Computer Science & Engineering, for providing the opportunity to undertake this seminar and
encouragement in the completion of this seminar.

We hereby wish to express our deep sense of gratitude to Dr. S Aparna, Project Coordinator, Department of
Computer Science and Engineering, School of Technology and to our guide, Mr. K. L. Narasimha Rao,
Assistant Professor, Department of Computer Science and Engineering, School of Technology for the
esteemed guidance, moral support and invaluable advice provided by them for the success of the project
report.

We are also thankful to all the Computer Science and Engineering department staff members who have
cooperated in making our seminar a success. We would like to thank all our parents and friends who
extended their help, encouragement, and moral support directly or indirectly in our seminar work.

Sincerely,

K. SIVA LAKSHMI POOJITHA - 222010312035


C. VEDA PRIYA - 222010312042
K. ONIKA SRI HARSHINI- 222010312052
N. SREE NITHYA - 222010312057
4
TABLE OF CONTENTS

TOPIC PAGE NO
ABSTRACT 6
ORGANISATION OF THE REPORT 7
1. INTRODUCTION

1.1 Python Programming Language 8

1.2 Applications of Python 10

2. SYSTEM REQUIREMENTS

2.1 Software Requirements 11

2.2 Hardware Requirements 11

3. IMPLEMENTATION AND RESULTS

3.1 Project Code 12

3.2 Results 17

4. CONCLUSION 20

5. REFERENCES 21

5
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.

6
ORGANIZATION OF THE REPORT
The report is divided into various chapters and is organized as follows:

Chapter 1: Introduction

This chapter includes brief introduction to Python Programming Language and its applications.

Chapter 2: System requirements

This chapter includes details of hardware and software requirements necessary for the execution of the
project.

Chapter 3: Implementation and Results

This chapter includes the program code of the project and the results of successful runs of the code.

Conclusion

This section includes the conclusion about the project.

References

This section includes the bibliographical references used for the development of the project.

7
CHAPTER 1

INTRODUCTION

1.1. Python Programming language

Python is one of the many open sources 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-

8
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.

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.

9
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 applications. You 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. Embedded applications - You can develop in Python.

7. Desktop applications – You can develop desktop application in Python using library like TKinter or QT.

10
CHAPTER 2

SYSTEM REQUIREMENTS

2.1 Software Requirements

PyCharm2019.1.1(Community Edition)

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 systems: Windows 10

Processor: intel core i5

Disk space:1Gb

11
CHAPTER 3

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.

3.2 Project Code:

import sys
import getpass
def hangman():
print("Get ready to play Hangman!")
word=getpass.getpass("Player 1, input your word: ").lower()
#turns the user inputted word into a lower case in one line
print('\n'*20)
#Spaces out the inputted word
start_game(word)
#calls back the function start_game
def start_game(word):
player_lives = 6
used_letters =[]
number_dashes=["_" for i in range(len(word))]
#Using list compression, set number_dashes to - - -....

12
print(visuals(player_lives))
print("")
print("")
print(" ".join(number_dashes))
#using join function, turns '-','-' to - -
while player_lives == player_lives:
#loops forever
input_letter =input("Player 2, input your letter guess: ")
print('\n'*20)
if len(input_letter) > 1:
#checks if the letter in imutted is more than 2 letters
player_lives-= 1
print(visuals(player_lives))
print(input_letter,"is not \'a letter\'!")
print("Used letters:"," ".join(used_letters))
print((updated_dashes(word,input_letter,number_dashes,)),'')
#takes away a life and prints visuals, progress, and used letters
elif input_letter not in used_letters and input_letter in word:
#Checks if the letter is in the word, and not used already
print(visuals(player_lives))
print("Correct,",input_letter,"is in the word!")
if input_letter not in used_letters:
used_letters.append(str(input_letter))
else:
pass
print("Used letters:"," ".join(used_letters))
print((updated_dashes(word,input_letter,number_dashes,)),'')
# prints new visuals, progress, and used letters
elif input_letter not in word :
#Checks if the letter guessed is not in the word
player_lives-=1
print(visuals(player_lives))
print("Incorrect,",input_letter,"is not in the word")
if input_letter not in used_letters:

13
used_letters.append(str(input_letter))
else:
pass
print("Used letters:"," ".join(used_letters))
print((updated_dashes(word,input_letter,number_dashes,)),'')
#takes away a life and prints new visuals, progress, and used letters
elif input_letter in used_letters:
#Finally checks if the letter is already used
player_lives-=1
print(visuals(player_lives))
print("You already guessed",input_letter)
if input_letter not in used_letters:
used_letters.append(str(input_letter))
else:
pass
print("Used letters:"," ".join(used_letters))
print((updated_dashes(word,input_letter,number_dashes,)),'')
# takes away a life and prints new visuals, progress, and used letters
if player_lives == 0:
you_lose(player_lives,word)
#Checks if the player loses, then calls back function: you_lose
elif word == "".join(number_dashes):
you_win(player_lives,word)
#Checks if the player wins, then calls back function: you_win
def updated_dashes(word,input_letter,number_dashes):
#everytime the player guesses a letter, it calls back thi function
for i in range(len(word)):
#loops based on length of word
if input_letter == word[i]:
#checks if the letter is equal to each letter individualy
number_dashes[i] = input_letter
#if so, sets the position in "- - -" to the inputted leter
return (" ".join(number_dashes))
#returns the updated progress "- - a" for example

14
def you_lose(player_lives,word):
#function is called back when player loses
print("The guesser loses!","The word was",word)
sys.exit()
#prints what the word was then exits the program
def you_win(player_lives,word):
#function is called back when player wins
print("The guesser wins!","The word was",word)
sys.exit()
#prints what the word was then exits the program
def visuals(player_lives):
#This function is used to print the progress through visuals
if player_lives == 6:
return"""
___
| |
|
|
|
|
|
|____
| |
"""
elif player_lives == 5:
return"""
___
| |
| O
|
|
|
|
|____

15
| |
"""
elif player_lives == 4:
return"""
___
| |
| O
| --|
|
|
|
|____
| |
"""
elif player_lives == 3:
return"""
___
| |
| O
| --|--
|
|
|
|____
| |
"""
elif player_lives == 2:
return"""
___
| |
| O
| --|--
| |
| |

16
|
|____
| |
"""
elif player_lives == 1:
return"""
___
| |
| O
| --|--
| |
| | |
|
|____
| |
"""
elif player_lives == 0:
return"""
___
| |
| l0
| |||
| |
| | |
|
|____
| D E A D|
"""
hangman ()

3.3 Results
Snapshots taken from successful runs of the project

17
Snaps
hot 3.1 output screen

Snaps
hot 3.2 output screen (true case)

18
Snaps
hot 3.3 output screen

Snap
shot 3.4 output screen (false case)

19
CONCLUSION

In the conclusion of this project, Hangman is a traditional game, typically played with words. It is 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 will be
writing a program to play a “guess a word letter-by-letter” version of hangman as shown above. You will

also be doing some statistical analysis of the words used in the Hangman game.

20
REFERENCES
Bibliography:

[1] “Python for everybody,” Charles Severance

[2] “Think Python,” Allen B. Downey [3]” Python programming”, Mark lutz

Websites:

[1]https://www.youtube.com/watch?v=QXeEoD0pB3E&list=PLsyeobzWxl7poL9JTVyndKe6

2ieoN-MZ3

[2]https://www.youtube.com/watch?v=NKVOjPHfiSA

[3] https://www.youtube.com/watch?v=BDi3SD7E6no

21

You might also like