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
77 changes: 77 additions & 0 deletions Rock_Paper_Scissors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!--Please do not remove this part-->
![Star Badge](https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=flat&color=BC4E99)
![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)
![Python](https://img.shields.io/badge/Python-3.x-blue)
![Beginner Friendly](https://img.shields.io/badge/Beginner-Friendly-brightgreen)

# Rock Paper Scissors

## 🛠️ Description

A simple command-line Rock Paper Scissors game written in Python. The player competes against the computer, which randomly selects Rock, Paper, or Scissors. The game determines the winner based on the classic rules.

## ⚙️ Languages or Frameworks Used

- Python 3
- Built-in modules:
- `random`

## 🌟 How to Run

Open a terminal in the project directory and run:

```bash
python rock_paper_scissors.py
```

If that doesn't work, try:

```bash
python3 rock_paper_scissors.py
```

## 🎮 Features

- Play against the computer
- Random computer choices
- Winner determination
- Simple and beginner-friendly code

## 📺 Demo

```text
Welcome to Rock, Paper, Scissors!
Best of 3 Rounds

Round 1
Enter rock, paper, or scissors: rock
You chose: rock
Computer chose: paper
Computer gets a point!

Round 2
Enter rock, paper, or scissors: paper
You chose: paper
Computer chose: rock
You get a point!

Round 3
Enter rock, paper, or scissors: rock
You chose: rock
Computer chose: rock
It's a tie!

Final Score
You: 1
Computer: 1
The game is a tie!

Do you want to play again? (yes/no): no
Thanks for playing!
```

## 🤖 Author

Dharani

GitHub: https://github.com/its-dharani
57 changes: 57 additions & 0 deletions Rock_Paper_Scissors/rockpaperscissors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import random

choices = ["rock", "paper", "scissors"]

print("Welcome to Rock, Paper, Scissors!")
print("Best of 3 Rounds")

while True:
user_score = 0
computer_score = 0
round = 0

while round < 3:
print("\nRound", round + 1)

user = input("Enter rock, paper, or scissors: ").lower()

if user not in choices:
print("Invalid choice")
continue

computer = random.choice(choices)

print("You chose:", user)
print("Computer chose:", computer)

if user == computer:
print("It's a tie!")
elif (
(user == "rock" and computer == "scissors") or
(user == "paper" and computer == "rock") or
(user == "scissors" and computer == "paper")
):
user_score += 1
print("You get a point!")
else:
computer_score += 1
print("Computer gets a point!")

round += 1

print("\nFinal Score")
print("You:", user_score)
print("Computer:", computer_score)

if user_score > computer_score:
print("You win the game!")
elif computer_score > user_score:
print("Computer wins the game!")
else:
print("The game is a tie!")

play_again = input("\nDo you want to play again? (yes/no): ").lower()

if play_again != "yes":
print("Thanks for playing!")
break