Cs File
Cs File
S
CA E
C. S
ANGELS’ A
CHOOL
“Words Guessing
Game”
Submitted To
By HARSHIT GAHLOT
Mrs. Lipi Gupta
12th B
UNDERTAKING
We declare that the work presented in this project titled
“Word Guessing Game”, submitted to Mrs. Lipi Gupta
(Computer Science) Angels’ Academy Sr. Sec. School for
the award of the CBSE class XII certificate. We have not
plagiarized or submitted the same work for the award
of any other examination. In case this undertaking is
found incorrect, we accept that our Certificates may be
unconditionally withdrawn.
Team Member
ABHINAV CHAUHAN - XII B
HARSHIT GAHLOT - XII B
VANSH TYAGI -XII B
Certicifate
Signature of
Internal Examiner
Lipi Gupta
(Computer Science)
Recommended :
Processor : Intel i5 9th Gen / Amd Ryzen 3 4nd Gen
Ram : 4GB
Space Reuired : 100GB
Os : Windows / Linux / macOS
Python Version 3.0.0 or Higher
Flow Of Program
Source Code
import random
word_categories = {
"tech": ["python", "javascript", "html", "css", "java",
"computer", "developer", "database", "algorithm",
"machine"],
"movies": ["inception", "avatar", "interstellar", "jaws",
"matrix", "titanic", "jurassic world", "gladiator",
"casablanca", "forrest", "pulpfiction", "forrestgump",
"shawshank", "thegodfather", "inception", "gladiator",
"jurassicpark", "terminator", "harrypotter", "fightclub"],
"games": ["minecraft", "resident evil", "cyberpunk", "gta
v", "pokemon", "bgmi", "fallout", "dota", "rise of tomb
raider", "spider man"],
"songs": ["kasam se", "tum hi ho", "tu", "tune jo na
kaha", "perfect", "lover", "sun maahi", "tu mileya", "until i
found you", "sleepless nights"]}
def choose_word(category):
return random.choice(word_categories[category])
def display_word(word, guessed_letters):
displayed_word = ""
for letter in word:
if letter == ' ':
displayed_word += ' '
elif letter in guessed_letters:
displayed_word += letter
else:
displayed_word += "_"
return displayed_word
def ask_play_again():
while True:
play_again = input("Do you want to play again?
(yes/no): ").lower()
if play_again == 'yes':
return True
elif play_again == 'no':
return False
else:
print("Invalid input. Please enter 'yes' or 'no'.")
def select_difficulty_level():
while True:
level = input("Select a difficulty level (easy/medium/hard):
").lower()
if level in difficulty_levels:
return difficulty_levels[level]
else:
print("Invalid difficulty level. Please choose from easy,
medium, or hard.")
def wordguess():
print("Welcome to Word Guessing Game - Tech Edition!")
while True:
category = input("Choose a category
(tech/movies/countries/games/songs): ").lower()
if category not in word_categories:
print("Invalid category. Please choose from tech, movies,
countries, games, or songs.")
continue
word_to_guess = choose_word(category)
guessed_letters = []
attempts = select_difficulty_level()
score = 0
while attempts > 0:
print("\nAttempts left:", attempts)
displayed = display_word(word_to_guess,
guessed_letters)
print(displayed)
if guess in guessed_letters:
print("You've already guessed that letter.")
continue
guessed_letters.append(guess)
if guess in word_to_guess:
print("Good guess!")
else:
print("Incorrect guess.")
attempts -= 1
if attempts == 0:
print("\nYou've run out of attempts. The word was:",
word_to_guess)
if not ask_play_again():
print("Thanks for playing!")
break
if __name__ == "__main__":
wordguess()
Output
Biblography
www.scribd.com
kvd1library.wordpress.com
www.youtube.com
Ncert Textbook