diff --git a/README.md b/README.md new file mode 100644 index 0000000..7cda040 --- /dev/null +++ b/README.md @@ -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. + +-------------------------- diff --git a/stone-paper-sssc.py b/stone-paper-sssc.py index 47c766f..38faf91 100644 --- a/stone-paper-sssc.py +++ b/stone-paper-sssc.py @@ -1,4 +1,4 @@ -import random, sys +import random print("Let's Play ROCK PAPER SCISSORS GAME!") @@ -6,54 +6,63 @@ 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!") +