From 1466c727e845b3da3ab20a5ee65ec3005b591c6a Mon Sep 17 00:00:00 2001 From: Haryaksh1 <154970822+Haryaksh1@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:21:54 +0530 Subject: [PATCH 1/3] =?UTF-8?q?Added=20Rock=E2=80=93Paper=E2=80=93Scissors?= =?UTF-8?q?=20game=20in=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented Rock–Paper–Scissors game with random computer choice, score tracking, and replay option. --- .../rock_paper_scissors.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Python/rock_paper_scissors/rock_paper_scissors.py diff --git a/Python/rock_paper_scissors/rock_paper_scissors.py b/Python/rock_paper_scissors/rock_paper_scissors.py new file mode 100644 index 0000000..6d06dd5 --- /dev/null +++ b/Python/rock_paper_scissors/rock_paper_scissors.py @@ -0,0 +1,50 @@ +import random + +def get_computer_choice(): + """Returns rock, paper, or scissors randomly for the computer.""" + return random.choice(["rock", "paper", "scissors"]) + +def determine_winner(player, computer): + """Determines the winner of a round.""" + if player == computer: + return "tie" + elif (player == "rock" and computer == "scissors") or \ + (player == "paper" and computer == "rock") or \ + (player == "scissors" and computer == "paper"): + return "player" + else: + return "computer" + +def main(): + print("🎮 Welcome to Rock–Paper–Scissors! 🎮") + print("Type 'rock', 'paper', or 'scissors'. Type 'q' to quit.\n") + + player_score = 0 + computer_score = 0 + + while True: + player = input("Your move: ").strip().lower() + if player == 'q': + break + if player not in ["rock", "paper", "scissors"]: + print("❌ Invalid input. Try again!\n") + continue + + computer = get_computer_choice() + print(f"Computer chose: {computer}") + + result = determine_winner(player, computer) + if result == "player": + print("✅ You win this round!\n") + player_score += 1 + elif result == "computer": + print("💻 Computer wins this round!\n") + computer_score += 1 + else: + print("🤝 It's a tie!\n") + + print(f"Final Score — You: {player_score}, Computer: {computer_score}") + print("Thanks for playing! 👋") + +if __name__ == "__main__": + main() From aa1396e9311dfa33786d25f37d7fb9611b929230 Mon Sep 17 00:00:00 2001 From: Haryaksh1 <154970822+Haryaksh1@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:23:12 +0530 Subject: [PATCH 2/3] =?UTF-8?q?Add=20README=20for=20Rock=E2=80=93Paper?= =?UTF-8?q?=E2=80=93Scissors=20game?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Python/rock_paper_scissors/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Python/rock_paper_scissors/README.md diff --git a/Python/rock_paper_scissors/README.md b/Python/rock_paper_scissors/README.md new file mode 100644 index 0000000..83611d3 --- /dev/null +++ b/Python/rock_paper_scissors/README.md @@ -0,0 +1,25 @@ +# 🎮 Rock–Paper–Scissors (Python) + +A simple console-based Rock–Paper–Scissors game written in Python. + +## 🚀 How to Run +```bash +python rock_paper_scissors.py +``` + +## 🧠 Features + +- Player vs Computer mode + +- Randomized computer choice + +- Keeps score + +- Option to quit anytime + + ## Example Output + +Your move (rock/paper/scissors): rock +Computer chose: scissors +✅ You win this round! +Play again? (y/n): y From a34d64475a3f2368dd9254425fc9069a9d88a86e Mon Sep 17 00:00:00 2001 From: Haryaksh1 <154970822+Haryaksh1@users.noreply.github.com> Date: Sat, 18 Oct 2025 18:38:10 +0530 Subject: [PATCH 3/3] =?UTF-8?q?Updated=20INDEX.md=20to=20include=20Rock?= =?UTF-8?q?=E2=80=93Paper=E2=80=93Scissors=20game?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- INDEX.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/INDEX.md b/INDEX.md index c9db9a6..7d9a81a 100644 --- a/INDEX.md +++ b/INDEX.md @@ -79,3 +79,6 @@ By now we have 2 numbers (variables), you and computer ### 🎯 [Whack_A_Mole](./Python/Whack_A_Mole/) - Language: Python + +### 🎯 [Rock–Paper–Scissors](python/rock_paper_scissors/) +- Language: Python