Index
SR .NO Topic name Pages.no
1 Introduction
2 Feature
3 Code
4 Output
5 Objective
6 Conclusion
7 Reference
INTRODUCTION
A word guessing game is a classic pastime that challenges players to deduce a hidden
word within a limited number of attempts. It’s a versatile game, adaptable for various
ages and skill levels, and can be played in numerous formats, from simple pen-and-paper
versions to sophisticated digital adaptations.
Core Concept:- The game revolves around a secret word that one player (or the
computer) selects.Other players attempt to guess the word by suggesting letters or, in
some variations, entire words.Feedback is provided to the guessers, typically indicating
which letters are present in the hidden word and their correct positions. The goal is to
correctly guess the word before running out of attempts.
5
FEATURE
1. Randomly selected words from a predefined list
2. Blank spaces representation of the word
3. Feedback on correct and incorrect guesses
4. Limited number of attempts
6
CODE
Import random
Def choose_word():
“””Chooses a random word from a list.”””
Words = [“apple”, “banana”, “orange”, “grape”, “watermelon”, “strawberry”,
“kiwi”, “mango”, “pineapple”, “blueberry”] # Add more words!
Return random.choice(words)
Def play_word_guessing_game():
“””Plays the word guessing game.”””
Secret_word = choose_word()
Word_letters = set(secret_word) # Letters in the word
Alphabet = set(chr(i) for I in range(ord(‘a’), ord(‘z’) + 1)) # All lowercase
alphabets
Used_letters = set() # What the user has guessed
Lives = 6 # Number of incorrect guesses allowed
While len(word_letters) > 0 and lives > 0:
# Letters used
Print(“You have used these letters: “, “ “.join(used_letters))
# Current word status
Word_list = [letter if letter in used_letters else ‘_’ for letter in secret_word]
Print(“Current word: “, “ “.join(word_list))
User_letter = input(“Guess a letter: “).lower()
If user_letter in alphabet – used_letters:
Used_letters.add(user_letter)
If user_letter in word_letters:
7
Word_letters.remove(user_letter)
Print(“Correct guess!”)
Else:
Lives -= 1 # Takes away a life
Print(“Letter is not in the word.”)
Elif user_letter in used_letters:
Print(“You have already used that character. Please try again.”)
Else:
Print(“Invalid character. Please try again.”)
# Game over conditions
If lives == 0:
Print(“You died, sorry. The word was”, secret_word)
Else:
Print(“You guessed the word”, secret_word, “!!”)
Play_word_guessing_game()
OUTPUT
9
OBJECTIVE
The objective of this project is to create an interactive word guessing game where the player
has to guess a randomly selected word from a predefined list of words. The game will
provide feedback on correct or incorrect guesses, and the player will have a limited number
of attempts to guess the word correctly.
REFERENCE
www.google.com
www.campusify.co.in
11
15