Professional Documents
Culture Documents
Project Report On Hangman Game
Project Report On Hangman Game
Project Report On Hangman Game
Submitted by-
NAME REG.NO. ROLL NO.
Rahul kumar 11912400 71
Shivshankar Soni 12111839 75
Sanjit kumar 12112200 02
TOPIC
1.INTRODUCTION
1.1 Python Programming Language
2. SYSTEM REQUIREMENTS
2.1 Software Requirements
3. OBJECTIVE
4. DESIGN: ER DIAGRAM AND DFD
5. IMPLEMENTATION AND RESULTS
3.1 Project Code
3.2. Results
CONCLUSION
REFERENCES
ORGANIZATION OF THE REPORT
Chapter 1: Introduction
This chapter includes brief introduction to Python Programming Language and
its applications.
Chapter 4: Objective
Conclusion
This section includes the conclusion about the project.
References
This section includes the bibliographical references used for the development
of the project.
CHAPTER 1
INTRODUCTION
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
67. 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.
69. 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.
70. 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.
71. 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.
72.
73. 8. Advanced features: Supports generators and list comprehensions. We will cover
these features later.
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.
CHAPTER 2
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
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.
window = Tk()
window.title('Hangman-GUESS CITIES NAME')
word_list=
['MUMBAI','DELHI','BANGLORE','HYDRABAD','AHMEDABAD','CHENNAI','KOLKATA','SU
RAT','PUNE','JAIPUR','AMRITSAR','ALLAHABAD','RANCHI',
'LUCKNOW','KANPUR','NAGPUR','INDORE','THANE','BHOPAL','PATNA','GHAZIABAD','
AGRA','FARIDABAD','MEERUT','RAJKOT','VARANASI','SRINAGAR',
'RAIPUR','KOTA','JHANSI']
photos = [PhotoImage(file="images/hang0.png"),
PhotoImage(file="images/hang1.png"), PhotoImage(file="images/hang2.png"),
PhotoImage(file="images/hang3.png"), PhotoImage(file="images/hang4.png"),
PhotoImage(file="images/hang5.png"),
PhotoImage(file="images/hang6.png"), PhotoImage(file="images/hang7.png"),
PhotoImage(file="images/hang8.png"),
PhotoImage(file="images/hang9.png"), PhotoImage(file="images/hang10.png"),
PhotoImage(file="images/hang11.png")]
def newGame():
global the_word_withSpaces
global numberOfGuesses
numberOfGuesses =0
the_word=random.choice(word_list)
the_word_withSpaces = " ".join(the_word)
lblWord.set(' '.join("_"*len(the_word)))
def guess(letter):
global numberOfGuesses
if numberOfGuesses<11:
txt = list(the_word_withSpaces)
guessed = list(lblWord.get())
if the_word_withSpaces.count(letter)>0:
for c in range(len(txt)):
if txt[c]==letter:
guessed[c]=letter
lblWord.set("".join(guessed))
if lblWord.get()==the_word_withSpaces:
messagebox.showinfo("Hangman","You guessed it!")
else:
numberOfGuesses += 1
imgLabel.config(image=photos[numberOfGuesses])
if numberOfGuesses==11:
messagebox.showwarning("Hangman","Game Over")
imgLabel=Label(window)
imgLabel.grid(row=0, column=0, columnspan=3, padx=10, pady=40)
lblWord = StringVar()
Label(window, textvariable =lblWord,font=('consolas 24 bold')).grid(row=0,
column=3 ,columnspan=6,padx=10)
n=0
for c in ascii_uppercase:
Button(window, text=c, command=lambda c=c: guess(c), font=('Helvetica
18'), width=4).grid(row=1+n//9,column=n%9)
n+=1
Button(window, text="New\nGame", command=lambda:newGame(), font=("Helvetica
10 bold")).grid(row=3, column=8)
newGame()
window.mainloop()
3.3 Results
Snapshot 3.3
Snapshot 3.4:output screen(false case)
REFERENCES
Bibliography:
[1] “Python for everybody”, Charles R.Severance [
Websites:
[1]https://www.youtube.com/watch?v=QXeEoD0pB3E&list=PLsyeobzWxl7poL9JTVyndKe 6 2ieoN-
MZ3
[2]https://www.youtube.com/watch?v=NKVOjPHfiSA
[3] https://www.youtube.com/watch?v=BDi3SD7E6no