11205 CHANDANA GJ CS IP
11205 CHANDANA GJ CS IP
GERUGAMBAKKAM, CHENNAI
COMPUTER SCIENCE INVESTIGATORY PROJECT
HANGMAN SUBMITTED BY
BONAFIDE G J CHANDANA
USN - 180146
ROLL NO. - 11205
XI - ‘B’
2024-2025
CERTIFICATE
1 Introduction to 1
python
2 Program analysis 2
3 Source code 3
4 Sample output 10
5 Reference 21
INTRODUCTION TO PYTHON
Python is an easy to use, interpreted, high-level programming language. It is an
expressive language that has so many convenient features which makes it highly
user friendly. Python’s simple syntax and high readability reduces cost for
program maintenance and makes it really efficient. Often, programmers fall in
love with Python because of the increased productivity it provides and a lot of
useful and fun applications and software can be made with it. Including this fun
little game ‘HANGMAN’.
Although it is not perfect, yet it has a lot of pluses and strengths which helped
me in a lot of ways to complete this project in time. Firstly, it is an interpreted
language which means there is no compilation step and the edit-test-debug cycle
is incredibly fast. I could repeatedly test the program and make the necessary
changes then and there itself without the need to complete the code. Speaking of
completing the program, I could not take the computer along with me wherever
I go. But python’s portability made it even easier to use. It’s a multi-platform
language so, I would type the code using other devices whenever its convenient.
Especially I used my smartphone to design the ASCII character for hangman.
For completing this program, I had to use few modules for specific functions.
There was no need to download those additional libraries because you get
everything while installing python. Its completeness is surely an advantage.
PROGRAM ANALYSIS
AIM:
To create “Hangman” game which is fun and knowledgeable using the concepts
learnt.
OBJECTIVE:
A number of dashes representing the word to be guessed along with its
corresponding clue will be displayed.
Using the clue and dashes which gets filled while playing with correct letters,
the player has to guess the word correctly.
The player cannot make more than 6 mistakes or the man will be hanged.
LOGIC USED:
Module used: Random module
While loop is used to iterate the program as long as the player has not made
more than 6 mistakes or not guessed the correct word yet.
For each iteration, the player is asked to guess a letter with the given clue.
Using if – else condition statements, if the guessed letter is correct, then an
appropriate message is displayed.
If not, when the guessed letter is incorrect, the number of lives decreases by one
and an alerting message is displayed. Also, the hangman character develops by
one step till the player makes 6 mistakes in total and loses the game.
In both cases, for each iteration, the player’s progress in guessing the word (i.e.,
mix of dashes and guessed words) along with number of lives left is displayed.
Once the game ends, the program asks the player for the choice of playing again
or not and the loop repeats or terminates respectively.
SOURCE CODE
#COMPUTER SCIENCE PROJECT
#HANGMAN
#initialize
play_again = ["y", "Y", "yes", "YES", "yeah", "Yeah"]
#imports
import random
#constants(ASCII hangman)
HANGMAN = ['''
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/''', '''
========
[] |
[] 0
[]
[]
[]---------/|
[] / |
---------+ /
---------+/''', '''
========
[] |
[] 0
[] |
[] |
[]---------/|
[] / |
---------+ /
---------+/''', '''
========
[] |
[] 0
[] /|
[] |
[]---------/|
[] / |
---------+ /
---------+/''', '''
========
[] |
[] 0
[] /|\\
[] |
[]---------/|
[] / |
---------+ /
---------+/''', '''
========
[] |
[] 0
[] /|\\
[] |
[]----/ ---/|
[] / |
---------+ /
---------+/''','''
========
[] |
[] 0
[] /|\\
[] |
[]----/ \\---/|
[] / |
---------+ /
---------+/''']
max_lives = len(HANGMAN)-1
#picking a word
word = random.choice(wordbank)
#MAIN LOOP
print('''
.__. .__. ___ .__ __. ______ .___ ___. ___ .__ __.
| | | | / \ | \ | | / ____| | \/ | / \ | \ | |
| |__| | / ^ \ | \| | | | __ | \ / | / ^ \ | \| |
| __ | / /_\ \ | . | | | |_ | | |\/| | / /_\ \ | . |
| | | | / _____ \ | |\ | | |__| | | | | | / _____ \ | |\ |
|__| |__| /__/ \__\ |__| \__| \______| |__| |__| /__/ \__\ |__| \__|
''')
print("""
Welcome to HANGMAN!!!
if current_guess == word:
print('YOU WON')
print('YES!!! the correct word was', word)
print('YOU BROKE FREE!!!!')
Welcome to HANGMAN!!!
CLUE: I'm a GOD, I'm a PLANET, I'm used to measure HEAT. What am I??
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: []
so far, the word is: _ _ _ _ _ _ _
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['E']
so far, the word is: _ E_ _ _ _ _
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['E', 'R']
so far, the word is: _ ER_ _ R_
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['E', 'R', 'Y']
so far, the word is: _ ER_ _ RY
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['E', 'R', 'Y', 'M']
so far, the word is: MER_ _ RY
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['E', 'R', 'Y', 'M', 'U']
so far, the word is: MER_ URY
YOU WON
YES!!! the correct word was MERCURY
YOU BROKE FREE!!!!
Would you like to play again ?!?!? no
Guessing the letters incorrectly(losing):
.__. .__. ___ .__ __. ______ .___ ___. ___ .__ __.
| | | | / \ | \ | | / ____| | \/ | / \ | \ | |
| |__| | / ^ \ | \| | | | __ | \ / | / ^ \ | \| |
| __ | / /_\ \ | . | | | |_ | | |\/| | / /_\ \ | . |
| | | | / _____ \ | |\ | | |__| | | | | | / _____ \ | |\ |
|__| |__| /__/ \__\ |__| \__| \______| |__| |__| /__/ \__\ |__| \__|
Welcome to HANGMAN!!!
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: []
so far, the word is: _ _ _ _ _ _ _ _ _ _
========
[] |
[] 0
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['J']
so far, the word is: _ _ _ _ _ _ _ _ _ _
========
[] |
[] 0
[] |
[] |
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['J', 'E']
so far, the word is: _ _ _ _ _ _ _ _ _ _
========
[] |
[] 0
[] /|
[] |
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['J', 'E', 'Q']
so far, the word is: _ _ _ _ _ _ _ _ _ _
========
[] |
[] 0
[] /|\
[] |
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['J', 'E', 'Q', 'Y']
so far, the word is: _ _ _ _ _ _ _ _ _ _
========
[] |
[] 0
[] /|\
[] |
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['J', 'E', 'Q', 'Y', 'N']
so far, the word is: _ _ _ _ _ N_ _ _ N
Enter your letter guess: p
========
[] |
[] 0
[] /|\
[] |
[]----/ ---/|
[] / |
---------+ /
---------+/
You have used the following letters: ['J', 'E', 'Q', 'Y', 'N', 'P']
so far, the word is: _ _ _ _ _ N_ _ _ N
========
[] |
[] 0
[] /|\
[] |
[]----/ \--/|
[] / |
---------+ /
---------+/
YOU LOST.
YOU HAVE BEEN HANGED.
The correct word was WASHINGTON
Would you like to play again ?!?!? no
Proceeding to play again:
.__. .__. ___ .__ __. ______ .___ ___. ___ .__ __.
| | | | / \ | \ | | / ____| | \/ | / \ | \ | |
| |__| | / ^ \ | \| | | | __ | \ / | / ^ \ | \| |
| __ | / /_\ \ | . | | | |_ | | |\/| | / /_\ \ | . |
| | | | / _____ \ | |\ | | |__| | | | | | / _____ \ | |\ |
|__| |__| /__/ \__\ |__| \__| \______| |__| |__| /__/ \__\ |__| \__|
Welcome to HANGMAN!!!
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: []
so far, the word is: _ _ _ _
========
[]
[]
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['N']
so far, the word is: _ _ _ N
========
[] |
[] 0
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['N', 'A']
so far, the word is: _ _ _ N
========
[] |
[] 0
[]
[]
[]---------/|
[] / |
---------+ /
---------+/
You have used the following letters: ['N', 'A', 'M']
so far, the word is: M_ _ N
YOU WON
YES!!! the correct word was MOON
YOU BROKE FREE!!!!
.__. .__. ___ .__ __. ______ .___ ___. ___ .__ __.
| | | | / \ | \ | | / ____| | \/ | / \ | \ | |
| |__| | / ^ \ | \| | | | __ | \ / | / ^ \ | \| |
| __ | / /_\ \ | . | | | |_ | | |\/| | / /_\ \ | . |
| | | | / _____ \ | |\ | | |__| | | | | | / _____ \ | |\ |
|__| |__| /__/ \__\ |__| \__| \______| |__| |__| /__/ \__\ |__| \__|
Welcome to HANGMAN!!!
Continues….
FUTURE SCOPES OF THIS PROJECT:
1. Enhancing User Experience :
Implementing graphical improvements with animations and sound effects.
Introducing hints and power-ups to make the game more interactive.
2. Expanding Game Modes
Multiplayer Mode: Allowing two or more players to compete online.
Challenge Mode: Timed levels where players must guess words within a set
time.
Adaptive Difficulty: The game adjusts based on the player’s performance.
3. Educational Applications
Using Hangman for language learning and vocabulary building.
Developing subject-specific versions (e.g., medical terms, coding concepts).
4.Virtual Reality (VR) & Augmented Reality (AR) :
Creating an immersive VR Hangman experience.
Using AR to visualize words and guesses in real-world environments.
5. Security & Fair Play Enhancements
Preventing cheating in online multiplayer using anti-cheat algorithms.
Blockchain-based secure word packs and authentication.
RESULT:
The game was launched and run successfully.
REFERENCE:
Class 11 textbook - “Progress in COMPUTER SCIENCE and getting
ahead with PYTHON” by Sumita Arora.
MJ codes – YouTube: https://youtu.be/wmSysRui0cI
NeuralNine – YouTube: https://youtu.be/5x6iAKdJB6U