0% found this document useful (0 votes)
1 views20 pages

IPCSOK

The document outlines a computer investigatory project on a Python-based Hangman game featuring five categories: Animals, Vegetables, Sports, Jobs, and Programming languages. It includes sections on introduction, salient features, system requirements, scope for improvement, code, output, and bibliography. The project emphasizes user-friendliness and portability across platforms while providing a structured code layout.

Uploaded by

sriranjani2008s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views20 pages

IPCSOK

The document outlines a computer investigatory project on a Python-based Hangman game featuring five categories: Animals, Vegetables, Sports, Jobs, and Programming languages. It includes sections on introduction, salient features, system requirements, scope for improvement, code, output, and bibliography. The project emphasizes user-friendliness and portability across platforms while providing a structured code layout.

Uploaded by

sriranjani2008s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

M.A.V.

VIDYASHRAM
COMPUTER INVESTIGATORY
PROJECT

TOPIC:

NAME:
CLASS:
SECTION:
ROLL NUMBER:
DATE:

1
INDEX
S.NO TOPIC PAGE NO
1. 3
Introduction
2. 4
Salient features
3. 5
System requirements
4. 6
Scope of improvement
5. 7
Code
6. 16
Output
7. 20
Bibliography

2
INTRODUCTION
The following python hangman game is provided for 5
categories:

1. Animals
2. Vegetables
3. Sports
4. Jobs
5. Programming languages

3
SALIENT FEATURES

 The program is compact


 The program is edited for errors
 The program can be run on any platform
 The program is structural
 The program is user friendly
 The program code is executed line by line
 The program has GUI programming support

4
SYSTEM REQUIREMENTS

 MAIN PROCESSOR :
Pentium III and above
 HARD DISK :

1 GB
 RAM :

1 GB
 OPERATING SYSTEM :

Windows XP and above


 COMPILER :

Python 3.1
 LANGUAGE :

Python

5
SCOPE OF IMPROVEMENT

 The program can be made simpler


 Comments can be used in the program
 The statements in the program can be
intended
 Blank lines and blank spaces can be used in
the program

6
CODE
def man6():
print(" ----------")
print(" | |")
print(" | |")
print(" | ")
print(" | ")
print(" | ")
print(" | ")
print(" | ")
print("--- ")
def man5():
print(" ----------")
print(" | |")
print(" | |")
print(" | O")
print(" | ")
print(" | ")
print(" | ")
print(" | ")
print("--- ")
def man4():
print(" ----------")
print(" | |")
print(" | |")
print(" | O")
print(" | | ")
print(" | ")
print(" | ")
print(" | ")
print("--- ")
def man3():
print(" ----------")
print(" | |")
print(" | |")
print(" | O")
print(" | /| ")
print(" | ")
print(" | ")
print(" | ")
print("--- ")
def man2():
7
print(" ----------")
print(" | |")
print(" | |")
print(" | O")
print(" | /|\ ")
print(" | ")
print(" | ")
print(" | ")
print("--- ")
def man1():
print(" ----------")
print(" | |")
print(" | |")
print(" | O")
print(" | /|\ ")
print(" | / ")
print(" | ")
print(" | ")
print("--- ")
def man0():
print(" ----------")
print(" | |")
print(" | |")
print(" | O")
print(" | /|\ ")
print(" | / \ ")
print(" | ")
print(" | ")
print("--- ")
import random
print("Hangman Game!!!")
while True:
n=random.randint(0,4)
animal=['leopard','cheetah','hyena','camel','gorilla']
vegetable=['lettuce','broccoli','turnip','brinjal','pumpkin']
sport=['rugby','judo','badminton','cricket','wrestling']
job=['salesperson','teacher','cashier','administrator','librarian']
language=['python','javascript','scala','pascal','swift']
ch=int(input('''Enter the no.of the genre in which you want to play the
game.
1.Animal
2.Vegetable
3.Sport

8
4.Job
5.Programming language '''))
ifch==1:
m=7
word=animal[n]
wordl=list(word)
out=[]
fori in range(len(word)):
out.append('_')
print(out)
while m!=0:
if '_' not in out:
print("Congratulations!!! You Won!!!")
break
else:
guess=input("Guess any letter:")
guess=guess.lower()
ifguess.isalpha()==False:
print("Not an alphabet")
break
iflen(guess)>1:
print("It is a string not an alphabet")
k=0
for j in range(len(word)):
ifwordl[j]==guess:
out[j]=guess
k+=1
if k==0:
print("Wrong guess.")
m-=1
print("You still have ",m," attempts.")
if m==6:
man6()
print(out)
elif m==5:
man5()
print(out)
elif m==4:
man4()
print(out)
elif m==3:
man3()
print(out)

9
elif m==2:
man2()
print(out)
elif m==1:
man1()
print(out)
elif m==0:
man0()
print("The answer is ",wordl)
print("You lose.Better luck next time.")
else:
print(out)
elifch==2:
m=7
word=vegetable[n]
wordl=list(word)
out=[]
fori in range(len(word)):
out.append('_')
print(out)
while m!=0:
if '_' not in out:
print("Congratulations!!! You Won!!!")
break
else:
guess=input("Guess any letter:")
guess=guess.lower()
ifguess.isalpha()==False:
print("Not an alphabet")
break
iflen(guess)>1:
print("It is a string not an alphabet")
k=0
for j in range(len(word)):
ifwordl[j]==guess:
out[j]=guess
k+=1
if k==0:
print("Wrong guess.")
m-=1
print("You still have ",m," attempts.")
if m==6:
man6()

10
print(out)
elif m==5:
man5()
print(out)
elif m==4:
man4()
print(out)
elif m==3:
man3()
print(out)
elif m==2:
man2()
print(out)
elif m==1:
man1()
print(out)
elif m==0:
man0()
print("The answer is ",wordl)
print("You lose.Better luck next time.")
else:
print(out)
elifch==3:
m=7
word=sport[n]
wordl=list(word)
out=[]
fori in range(len(word)):
out.append('_')
print(out)
while m!=0:
if '_' not in out:
print("Congratulations!!! You Won!!!")
break
else:
guess=input("Guess any letter:")
guess=guess.lower()
ifguess.isalpha()==False:
print("Not an alphabet")
break
iflen(guess)>1:
print("It is a string not an alphabet")
k=0

11
for j in range(len(word)):
ifwordl[j]==guess:
out[j]=guess
k+=1
if k==0:
print("Wrong guess.")
m-=1
print("You still have ",m," attempts.")
if m==6:
man6()
print(out)
elif m==5:
man5()
print(out)
elif m==4:
man4()
print(out)
elif m==3:
man3()
print(out)
elif m==2:
man2()
print(out)
elif m==1:
man1()
print(out)
elif m==0:
man0()
print("The answer is ",wordl)
print("You lose.Better luck next time.")
else:
print(out)
elifch==4:
m=7
word=job[n]
wordl=list(word)
out=[]
fori in range(len(word)):
out.append('_')
print(out)
while m!=0:
if '_' not in out:
print("Congratulations!!! You Won!!!")

12
break
else:
guess=input("Guess any letter:")
guess=guess.lower()
ifguess.isalpha()==False:
print("Not an alphabet")
break
iflen(guess)>1:
print("It is a string not an alphabet")
k=0
for j in range(len(word)):
ifwordl[j]==guess:
out[j]=guess
k+=1
if k==0:
print("Wrong guess.")
m-=1
print("You still have ",m," attempts.")
if m==6:
man6()
print(out)
elif m==5:
man5()
print(out)
elif m==4:
man4()
print(out)
elif m==3:
man3()
print(out)
elif m==2:
man2()
print(out)
elif m==1:
man1()
print(out)
elif m==0:
man0()
print("The answer is ",wordl)
print("You lose.Better luck next time.")
else:
print(out)
elifch==5:

13
m=7
word=language[n]
wordl=list(word)
out=[]
fori in range(len(word)):
out.append('_')
print(out)
while m!=0:
if '_' not in out:
print("Congratulations!!! You Won!!!")
break
else:
guess=input("Guess any letter:")
guess=guess.lower()
ifguess.isalpha()==False:
print("Not an alphabet")
break
iflen(guess)>1:
print("It is a string not an alphabet")
k=0
for j in range(len(word)):
ifwordl[j]==guess:
out[j]=guess
k+=1
if k==0:
print("Wrong guess.")
m-=1
print("You still have ",m," attempts.")
if m==6:
man6()
print(out)
elif m==5:
man5()
print(out)
elif m==4:
man4()
print(out)
elif m==3:
man3()
print(out)
elif m==2:
man2()
print(out)

14
elif m==1:
man1()
print(out)
elif m==0:
man0()
print("The answer is ",wordl)
print("You lose.Better luck next time.")
else:
print(out)
else:
print("Invalid option")
put=int(input("Enter 1 to Continue and 0 to Exit"))
if put==0:
print("Thanks for playing")
break
elif put==1:
pass
else:
print("Invalid option")

15
OUTPUT

16
17
18
19
BIBLIOGRAPHY

1. Sribd
2. Python.org
3. Python Book by Sumiti Arora
4. GeeksForGeeks

20

You might also like