FACULTY OF:
Faculty of Sciences
DEPARTMENT:
Computer Science
DEGREE TITLE:
Bs-Artificial Intelligence
SECTION:
M-1
SUBJECT TITLE:
Introduction to Programming
SUBJECT CODE:
CS-308
POJECT TITLE:
Range-Based Arithmetic
Calculator
SUBMITTED TO:
Mr. Ahsan Raza Sattar
SUBMITTED BY:
• Muhammad Abdullah (2024-ag-5287)
• Fakhar Alam (2024-ag-7440)
Contents:
1) Introduction
2) Features
3) How the Game Works
4) Game Rules
5) Source Code
4) Sample Gameplay
6) Conclusion
Project Title:
Rock-Paper-Scissors Game
Introduction:
A simple implementation of the classic Rock-Paper-Scissors
game.
The user plays against the computer, which selects its
move randomly.
A great way to learn the basics of Python programming.
Covers essential concepts like:
User input
Conditional logic (if, elif, else)
Loops (for replaying the game)
Random number generation
Fun and interactive project for beginners in Python.
🔧 Features
Random computer choices using Python's
random module.
Continuous gameplay until the user decides to
Quit
Clear instructions and feedback after every
round
Handles invalid inputs gracefully
How the Game Works:
1)Welcome Message: The game greets the user.
2)User Input:
Prompts the user to enter rock, paper, scissors, or quit.
If the input is invalid, the game displays an error message and asks again.
3)Computer Move:
The computer randomly selects one of the three valid choices.
4)Winner Determination:
If both choices are the same: Tie
If user's choice beats the computer's: User Wins
Otherwise: User Loses
5) Repeat: The game continues in a loop until the user types 'quit'.
Game Rules:
Player Computer Result
Rock Scissor You Win
Rock Paper You lose
Paper Rock You Win
Paper Scissor You lose
Scissor Paper You Win
Scissor Rock You lose
Source Code :
Code Break-Down:
1. User Input:
user_choice = input("Enter your choice (rock, paper, scissors or
'quit' to exit): ").lower()
Takes the user's input and converts it to lowercase.
Expected values: "rock", "paper", "scissors", or "quit".
2. Exit Condition:
if user_choice == 'quit':
print("Thanks for playing! Goodbye!")
Break
Ends the game loop if the user types 'quit'.
3. Input Validation:
if user_choice not in choices:
print("Invalid choice. Please choose rock, paper, or scissors.")
continue
Checks whether the input is valid.
If not, it displays a message and restarts the loop.
Computer's Random Choice:
computer_choice = random.choice(choices)print(f"Computer
chose: {computer_choice}")
The computer selects randomly from ["rock", "paper",
"scissors"].
Compare Choices and Decide Outcome:
if user_choice == computer_choice:
print("It's a tie!")elif (
(user_choice == "rock" and computer_choice == "scissors") or
(user_choice == "paper" and computer_choice == "rock") or
(user_choice == "scissors" and computer_choice == "paper")
):
print("You win!")else:
print("You lose!")
Compares the user’s and computer’s choices.
Displays the result based on standard game rules.
Loop Structure
while True:
...
Keeps the game running until the user quits.
Sample GamePlay:
Conclusion:
This game is an excellent beginner project that teaches:
Basic conditional statements (if, elif, else)
Using loops (while)
Working with user input and validation
Random choice generation with Python's random module
Perfect for learning and having fun at the same time!