Tamil Selvan (Number Gussing Program)
Tamil Selvan (Number Gussing Program)
INDEX
1. PROBLEM DEFINITION
1.1 Introduction
The Number Guessing Game is a simple Python-based game where players attempt to guess a randomly
selected number within a specific range. The game offers a user-friendly interface and immediate
feedback, making it suitable for users of all ages.
1.2 Features
Simple Interface: The game operates via text input, ensuring accessibility.
Feedback Mechanism: Players are informed if their guesses are too high or too low.
Randomized Gameplay: Each session generates a new random number.
Score Tracking: Tracks the number of attempts made by the user.
Customizable Range: The number range can be adjusted to vary difficulty.
2. PROBLEM ANALYSIS
2.1 Existing System
Traditional guessing games are often played manually, requiring a moderator to select and keep track of
the target number. Challenges in this approach include:
4. FUTURE ENHANCEMENTS
Add a graphical user interface (GUI) for an enhanced experience.
Introduce difficulty levels (easy, medium, hard).
Implement a leaderboard to track players’ performance.
Enable multiplayer mode.
Integrate sounds and animations.
5. SOURCE CODE
python
Copy code
import random
def start_game():
print("\nWelcome to the Number Guessing Game!")
print("I have selected a number between 1 and 100. Can you guess it?")
number = random.randint(1, 100)
attempts = 0
while True:
try:
guess = int(input("\nEnter your guess: "))
attempts += 1
if guess < number:
print("Too low! Try again.")
elif guess > number:
print("Too high! Try again.")
else:
print(f"Congratulations! You guessed the number in {attempts} attempts!")
break
except ValueError:
print("Invalid input. Please enter a valid number.")
if __name__ == "__main__":
start_game()
6. OUTPUT
Game Start:
css
Copy code
Welcome to the Number Guessing Game!
I have selected a number between 1 and 100. Can you guess it?
User Input and Feedback:
mathematica
Copy code
Enter your guess: 50
Too low! Try again.
7. BIBLIOGRAPHY
Programming in Python by John Zelle
Python Crash Course by Eric Matthes
8. WEBLIOGRAPHY
www.python.org
www.geeksforgeeks.org