Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
🎮 ROCK PAPER SCISSORS GAME

A beginner-friendly **Rock, Paper, Scissors** game written in Python. Play against the computer, track your score, and enjoy a simple but fun experience!

-------------------------

📋 Features

- Play Rock, Paper, Scissors against the computer
- Tracks wins, losses, and ties
- User-friendly interface
- Great for Python beginners to learn conditionals, loops, and input handling

-------------------------

🎮 How to Play

Press:
R for Rock
P for Paper
S for Scissors
Q to Quit the game

The computer will choose a move at random and the result will be shown immediately.

--------------------------
93 changes: 51 additions & 42 deletions stone-paper-sssc.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,68 @@
import random, sys
import random

print("Let's Play ROCK PAPER SCISSORS GAME!")

wins = 0
losses = 0
ties = 0


while True:
print("Current streak: %s Wins, %s Losses, %s Ties" % (wins, losses, ties))
try:
total_rounds = int(input("How many rounds would you like to play? (e.g., 3, 5): "))
if total_rounds > 0:
break
else:
print("Please enter a positive number.")
except ValueError:
print("Invalid input. Please enter a number.")

round_num = 1

while round_num <= total_rounds:
print(f"\nRound {round_num} of {total_rounds}")
print(f"Current score: {wins} Wins, {losses} Losses, {ties} Ties")


while True:
print("Type 'Q' to quit \n'R' for ROCK, 'P' for PAPER, 'S' for SCISSORS")
playermove = input().upper()
if playermove == "Q":
sys.exit()
if playermove == "R" or playermove == "P" or playermove == "S":
print("Type 'R' for ROCK, 'P' for PAPER, 'S' for SCISSORS")
playermove = input("Your move: ").upper()
if playermove in ["R", "P", "S"]:
break
else:
print("Invalid input. Try again.")


moves = {"R": "ROCK", "P": "PAPER", "S": "SCISSORS"}
print(f"{moves[playermove]} versus...")


compMove = random.choice(["R", "P", "S"])
print(moves[compMove])

if playermove == "R":
print("ROCK versus...")
if playermove == "P":
print("PAPER versus...")
if playermove == "S":
print("SCISSORS versus...")

randomNum = random.randint(1, 3)
if randomNum == 1:
compMove = "R"
print("ROCK")
if randomNum == 2:
compMove = "P"
print("PAPER")
if randomNum == 3:
compMove = "S"
print("SCISSORS")

if playermove == compMove:
print("It's a tie!")
ties += 1
elif playermove == "R" and compMove == "P":
print("It's a loss!")
losses += 1
elif playermove == "R" and compMove == "S":
print("It's a win!")
wins += 1
elif playermove == "P" and compMove == "S":
print("It's a loss!")
losses += 1
elif playermove == "P" and compMove == "R":
print("It's a win!")
wins += 1
elif playermove == "S" and compMove == "R":
print("It's a loss!")
losses += 1
elif playermove == "S" and compMove == "P":
print("It's a win!")
elif (playermove == "R" and compMove == "S") or \
(playermove == "P" and compMove == "R") or \
(playermove == "S" and compMove == "P"):
print("You win this round!")
wins += 1
else:
print("Thanks for trying my game")
print("You lose this round!")
losses += 1

round_num += 1


print("\n--- GAME OVER ---")
print(f"Final score: {wins} Wins, {losses} Losses, {ties} Ties")

if wins > losses:
print("🎉 You are the overall winner!")
elif losses > wins:
print("😢 You lost the game. Better luck next time!")
else:
print("😐 It's a tie overall!")