Rrock Deepikaaaaa
Rrock Deepikaaaaa
Objective
The object of the hangman is to guess the secret word before the stick
figure is hung. Players take turns selecting letters to narrow the word
down.
CERTIFICATE
This is to certify that candidate ROCK DEV has successfully completed the
project work entitled HANGMAN GAME in the subject Information
Practices laid down in the regulations of CBSE for the purpose of Practical
[ SHIVANI SHARMA]
PGT Comp. Science
___________________ ________________
Malviya convent school,
Jaipur(raj.)
CERTIFICATE
[ SHIVANI SHARMA]
PGT Comp. Science
___________________ ________________
SR. DESCRIPTION PAGE
NO.
NO.
1 ACKNOWLEDGEMENT
2 INTRODUCTION
4 PROPOSED SYSTEM
6 FLOW CHART
7 SOURCE CODE
8 OUTPUT
● A simple interactive system that asks user for input for each letter
and game. ·
● A simple visual interface that draws the hangman as
the game progresses.
This game selects given string word from the file and asks you to guess
character for that word. You will get 8 chances to guess a word.
One player thinks of a word and the other tries to guess it by guessing
letters. Each incorrect guess brings you closer to being "hanged." This
game helps to sharpen children's spelling and word-decoding skills
SYSTEM DEVELOPMENT AND LIFE CYCLE
● First, we will ask for the name of the user. We will take the user
input using the input() method. After execution, the input()
method takes the input from the user and returns a string.
● Next, we will select a word and ask the user to start guessing the
characters in the word.
● We will also define the maximum number of attempts the user
can take.
● Now, we will use a while loop to repeatedly ask the user to guess
the character until the attempts are exhausted.
● Inside the while loop, if the user guesses the correct character.
We will include it in the response. Otherwise, we will notify the
user that they made a mistake.
● If the user is able to guess all the characters of the word within
the maximum number of attempts, they win the game.
● If the user exhausts all their attempts before guessing the entire
word, they lose.
FLOW CHARTS
SOURCE CODE
#importing the time module
import time
#welcoming the user
name = input("What is your name? ")
print ("Hello, " + name, "Time to play
hangman!")
#wait for 1 second
time.sleep(1)
print ("Start guessing...")
time.sleep(0.5)
#here we set the secret. You can select any
word to play with.
word = ("secret",”principles”,”)
#creates an variable with an empty value
guesses = ' '
#determine the number of turns
turns = 10
# Create a while loop
#check if the turns are more than zero
while turns > 0:
# make a counter that starts with zero
failed = 0
# for every character in secret_word for char in
word:
# see if the character is in the players guess
if char in guesses:
# print then out the character
print (char,end=""),
else:
# if not found, print a dash
print ("_",end=""),
# and increase the failed counter with one
failed += 1
# if failed is equal to zero
# print You Won
if failed == 0:
print ("You won")
# exit the script
break
# ask the user go guess a character
guess = input("guess a character:")
# set the players guess to guesses
guesses += guess
# if the guess is not found in the secret word
if guess not in word:
# turns counter decreases with 1 (now 9)
turns -= 1
# print wrong
print ("Wrong")
# how many turns are left
print ("You have", + turns, 'more guesses' )
# if the turns are equal to zero
if turns == 0:
# print "You Lose"
print ("You Lose" )
OUTPUT:
What is your name? Deepika
Hello, Deepika Time to play hangman!
Start guessing...
______guess a character:s
s_____guess a character:e
se__e_guess a character:c
sec_e_guess a character:r
secre_guess a character:e
secre_guess a character:t
secret You won
● NCERT BOOKS
● https://www.wikipedia.com
● https://www.w3schools.com