0% found this document useful (0 votes)
5 views

Cs File

Uploaded by

t18017583
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)
5 views

Cs File

Uploaded by

t18017583
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/ 17

DEMY SR.

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

Certified that the work contained in


the project titled
“Word Guessing Game”, by:
“Abhinav , Harshit , Vansh ”, has
been carried out
under my supervision and that this
work has not been submitted
elsewhere for a CBSE certificate.

Signature of
Internal Examiner

Lipi Gupta
(Computer Science)

Angels’ Academy Signature of


Sr. Sec. School External Examiner
Acknowledge
We would like to thank Mrs. Rashmi
Chauhan Principal Angels’ Academy
Sr. Sec. School We are deeply
indebted to our mentor Mrs. Lipi
Gupta. We further thank to all the
staff members of Angels’ Academy Sr.
Sec. School , Haridwar . We owe our
sincere gratitude towards Angels’
Academy Team Our heartfelt thanks
to CBSE.
We also express our deepest gratitude
to our parents. Finally, we would like
to wind up by paying our heartfelt
thanks to all our near and dear ones.
Content

1. Introduction to The Project


2. System Requirement of the Project
3. Flow Of The Project
4. Python Coding
5. Output Of the Project
6. References
Introduction
Creating a program that can play a game comes
down to carefully considering all the possible
situations the Al can be in and how it should
respond in each of those situations. This is a
Python script of the classic game "Word
Guessing". The word to guess is represented by a
row of dashes. If the player guess a letter which
exists in the word, the script writes it in all its
correct positions. The player has turns to guess
the word according to difficulty level .
Objective Of This Project :
The objective of this project is to let the students
apply the programming knowledge into a real-
world situation/problem and exposed the
students how programming skills helps in
developing a good software.
1. Write programs utilizing modern software
tools. Apply object oriented programming
principles effectively when developing small
to medium sized projects.
2. Write effective procedural code to solve
small to medium sized problems.
3. Students will demonstrate a breadth of
knowledge in computer science, as
exemplified in the areas of systems, theory
and software development.
4. Students will demonstrate ability to conduct
a research or applied Computer Science
project, requiring writing and presentation
skills which exemplify scholarly style in
computer science.
System Requirements
Minimum :
Processor : Intel Duo Core / Amd Ryzen 2nd Gen
Ram : 2GB
Space Reuired : 50GB
Os : Windows / Linux / macOS
Python Version 3.0.0 or Higher

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"]}

difficulty_levels = {"easy": 10, "medium": 8, "hard": 5}

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)

guess = input("Guess a letter: ").lower()

if len(guess) != 1 or not guess.isalpha():


print("Please enter a valid single letter.")
continue

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 "_" not in display_word(word_to_guess,


guessed_letters):
print("\nCongratulations! You've guessed the word:",
word_to_guess)
score += attempts
break

if attempts == 0:
print("\nYou've run out of attempts. The word was:",
word_to_guess)

print("Your score for this game:", score)

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

You might also like