Target Score Game Using
Python
A CBSE Class XI Computer Science Project
Tools & Libraries
Python Programming Language
Python is a high-level, interpreted programming language
known for its simple and readable syntax. It is perfect for
beginners and supports multiple programming paradigms
including procedural, object-oriented, and functional
programming.
random Module
The random module in Python helps generate random numbers
and make random choices. In our game, it is used to generate
unpredictable scores between 1 and 10, making each game
session unique and exciting.
Software Requirements
Operating System Code Editor
Any modern operating system works perfectly: Windows You can use IDLE (comes with Python), Visual Studio
10 or later, macOS 10.15+, or Linux distributions like Code, PyCharm, or even a simple text editor like
Ubuntu 20.04 and above. Notepad++ for writing your code.
Python Version Hardware Requirements
Python 3.6 or higher is recommended. The latest stable Minimum 2 GB RAM, 1 GHz processor, and 100 MB free
version ensures all features work correctly and provides disk space. Most modern computers easily meet these
better error messages for learning. basic requirements.
Algorithm / Approach
The Target Score Game follows a logical sequence of steps to create an interactive gaming experience:
Start Program
Initialize the game and welcome the player
Set Target Score
Ask user to enter the winning score they want to reach
Take User Choice
Get player's decision to roll or quit the game
Generate Random Score
Use random module to create a score between 1 and 10
Update Total Score
Add the generated score to the player's running total
Check Winning Condition
Compare total score with target to determine if player won
Repeat or End Program
Continue rolling or display final result and exit
Program Flow
The game executes in a clear sequence that demonstrates programming logic:
Start
1
Game initialization and welcome message
User Input
2
Target score entry and roll/quit choice
Random Generation
3
Score between 1-10 created using random module
Score Update
4
Running total calculation and display
Condition Check
5
Win/lose status evaluation
Result Display
6
Victory or continue message shown
Exit
7
Game ends or restarts based on choice
Python Source Code
# Target Score Game - Python Implementation
# No functions used, only loops and conditionals
import random
# Welcome message
print("Welcome to Target Score Game!")
print("Roll the dice to reach your target score.")
print("-" * 40)
# Get target score from user
target = int(input("Enter your target score: "))
# Initialize variables
total_score = 0
roll_count = 0
# Main game loop
while total_score < target:
# Ask user if they want to roll
choice = input("\nDo you want to roll? (yes/no): ").lower()
if choice == "yes" or choice == "y":
# Generate random score between 1 and 10
score = [Link](1, 10)
total_score += score
roll_count += 1
# Display current roll and total
print(f"Roll {roll_count}: You got {score}")
print(f"Total Score: {total_score}")
# Check if target reached
if total_score >= target:
print("\n
Sample Output
Example Game Session:
Welcome to Target Score Game!
Roll the dice to reach your target score.
----------------------------------------
Enter your target score: 25
Do you want to roll? (yes/no): yes
Roll 1: You got 7
Total Score: 7
Do you want to roll? (yes/no): yes
Roll 2: You got 3
Total Score: 10
Do you want to roll? (yes/no): yes
Roll 3: You got 9
Total Score: 19
Do you want to roll? (yes/no): yes
Roll 4: You got 6
Total Score: 25
ï Congratulations! You reached the target!
You won in 4 rolls!
Thank you for playing Target Score Game!
Key Features & Learning Outcomes
Interactive User Input Random Number Generation
The program takes dynamic input from users, The random module creates unpredictable scores
allowing them to control the game flow by choosing between 1 and 10, making each game session
to roll or quit at any time. different and more engaging for players.
Loop Control Conditional Logic
The while loop continues execution until the target if-elif-else statements handle different user choices
score is reached or the player chooses to quit, and game conditions, showing how programs make
demonstrating loop logic perfectly. decisions based on input.
Score Tracking Clear Output Display
Variables track roll count and total score throughout Well-formatted messages show current status,
the game, demonstrating how data is stored and helping users understand the game progress and
updated during program execution. final results clearly.
Conclusion
What We Learned Python Understanding
This project helped us Working on this game
understand fundamental improved our understanding of
programming concepts like Python syntax, variable
loops, conditionals, and user management, and program
input handling. We learned how flow control. We practiced
to use the random module to writing clean, readable code
create unpredictable game with proper indentation and
behavior. comments.
Logic Development
The project emphasized the importance of logical thinking in
programming. We learned to break problems into smaller steps
and implement solutions systematically.
Practical Application
Creating a working game showed us how theoretical concepts
translate into real applications, making learning more
meaningful and enjoyable.
References
This project was developed using the following educational
resources:
NCERT Computer Science Textbook
Class XI - Chapters on Python programming, control structures,
and data types. Published by National Council of Educational
Research and Training.
Official Python Documentation
[Link] - Comprehensive documentation on Python syntax,
modules, and programming concepts. Available at
[Link]
W3Schools Python Tutorial
Beginner-friendly Python tutorials covering loops, conditionals,
and random module. Available at [Link]
Additional Resources
Python Programming by John Zelle, Online coding platforms
like GeeksforGeeks and Programiz for additional practice and
examples.