Skip to content

Commit 7f2cf85

Browse files
authored
Merge pull request #1 from bbob122/new_features
New Version of RPS game with new features.
2 parents 551e3b2 + 8e548c5 commit 7f2cf85

File tree

6 files changed

+188
-1
lines changed

6 files changed

+188
-1
lines changed

Diff for: Pomodoro Timer/pomodoro.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import time
2+
3+
def countdown(minutes):
4+
seconds = minutes * 60
5+
while seconds:
6+
mins, secs = divmod(seconds, 60)
7+
timer = f'{mins:02d}:{secs:02d}'
8+
print(timer, end='\r')
9+
time.sleep(1)
10+
seconds -= 1
11+
print('Time is up!')
12+
13+
# Example usage:
14+
countdown(1) # for a 25-minute work session
15+
countdown(1) # for a 5-minute break

Diff for: Python-Scripts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 3ad8293b0b314dfc0724b03d772dcef31e48cf15

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ More information on contributing and the general code of conduct for discussion
9393
| QR Code Generator | [QR Code Generator](https://github.com/DhanushNehru/Python-Scripts/tree/master/QR%20Code%20Generator) | This is generate a QR code from the provided link |
9494
| Random Color Generator | [Random Color Generator](https://github.com/DhanushNehru/Python-Scripts/tree/master/Random%20Color%20Generator) | A random color generator that will show you the color and values! |
9595
| Remove Background | [Remove Background](https://github.com/DhanushNehru/Python-Scripts/tree/master/Remove%20Background) | Removes the background of images. |
96-
| ROCK-PAPER-SCISSOR | [ROCK-PAPER-SCISSOR](https://github.com/DhanushNehru/Python-Scripts/tree/master/Rock%20Paper%20Scissor) | A game of Rock Paper Scissors. |
96+
| ROCK-PAPER-SCISSOR | [ROCK-PAPER-SCISSOR](https://github.com/DhanushNehru/Python-Scripts/tree/master/Rock%20Paper%20Scissor) | A game of Rock Paper Scissors.
97+
| Rock Paper Scissors -New | [Rock Paper Scissors -New](https://github.com/bbob122/Python-Scripts/tree/new_features/Rock%20Paper%20Scissors%20-New) | Updated Rock Paper Scissors with new feature. |
9798
| Run Then Notify | [Run Then Notify](https://github.com/DhanushNehru/Python-Scripts/tree/master/Run%20Then%20Notify) | Runs a slow command and emails you when it completes execution. |
9899
| Selfie with Python | [Selfie_with_Python](https://github.com/DhanushNehru/Python-Scripts/tree/master/Selfie%20with%20Python) | Take your selfie with python . |
99100
| Simple TCP Chat Server | [Simple TCP Chat Server](https://github.com/DhanushNehru/Python-Scripts/tree/master/TCP%20Chat%20Server) | Creates a local server on your LAN for receiving and sending messages! |

Diff for: Rock Paper Scissors - New Version

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import random
2+
3+
def get_user_choice():
4+
choices = ["rock", "paper", "scissors", "lizard", "spock"]
5+
user_choice = input("Enter your choice (rock, paper, scissors, lizard, spock): ").lower()
6+
while user_choice not in choices:
7+
user_choice = input("Invalid choice. Please enter rock, paper, scissors, lizard, or spock: ").lower()
8+
return user_choice
9+
10+
def get_computer_choice():
11+
choices = ["rock", "paper", "scissors", "lizard", "spock"]
12+
return random.choice(choices)
13+
14+
def determine_winner(user_choice, computer_choice):
15+
win_conditions = {
16+
"scissors": ["paper", "lizard"],
17+
"paper": ["rock", "spock"],
18+
"rock": ["lizard", "scissors"],
19+
"lizard": ["spock", "paper"],
20+
"spock": ["scissors", "rock"]
21+
}
22+
23+
if user_choice == computer_choice:
24+
return "tie"
25+
elif computer_choice in win_conditions[user_choice]:
26+
return "user"
27+
else:
28+
return "computer"
29+
30+
def play_game():
31+
print("Welcome to Rock, Paper, Scissors, Lizard, Spock!")
32+
33+
user_choice = get_user_choice()
34+
computer_choice = get_computer_choice()
35+
36+
print(f"You chose: {user_choice}")
37+
print(f"Computer chose: {computer_choice}")
38+
39+
winner = determine_winner(user_choice, computer_choice)
40+
41+
if winner == "tie":
42+
print("It's a tie! Let's play again.")
43+
play_game()
44+
elif winner == "user":
45+
print("You win!")
46+
else:
47+
print("Computer wins!")
48+
49+
if __name__ == "__main__":
50+
play_game()

Diff for: Rock Paper Scissors -New/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Rock, Paper, Scissors, Lizard, Spock Game
2+
3+
This is a Python implementation of the classic Rock, Paper, Scissors game extended with two additional options: Lizard and Spock.
4+
5+
## Rules
6+
7+
- **Scissors** cuts **Paper**
8+
- **Paper** covers **Rock**
9+
- **Rock** crushes **Lizard**
10+
- **Lizard** poisons **Spock**
11+
- **Spock** smashes **Scissors**
12+
- **Scissors** decapitates **Lizard**
13+
- **Lizard** eats **Paper**
14+
- **Paper** disproves **Spock**
15+
- **Spock** vaporizes **Rock**
16+
- **Rock** crushes **Scissors**
17+
18+
## How to Play
19+
20+
1. **Setup:** Run the Python script `rps.py`.
21+
2. **Gameplay:**
22+
- Enter the number of rounds you want to play.
23+
- For each round, enter your choice: rock, paper, scissors, lizard, or spock.
24+
- The computer will randomly select its choice.
25+
- The winner of each round is determined based on the rules above.
26+
- Scores (user wins, computer wins, and ties) are displayed after each round.
27+
3. **End of Game:**
28+
- After completing all rounds, final scores are displayed.
29+
- You have the option to play again or exit.
30+

Diff for: Rock Paper Scissors -New/rps.py

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import random
2+
3+
choices = ["rock", "paper", "scissors", "lizard", "spock"]
4+
5+
def get_user_choice():
6+
user_choice = input("Enter your choice (rock, paper, scissors, lizard, spock): ").lower()
7+
while user_choice not in choices:
8+
user_choice = input("Invalid choice. Please enter rock, paper, scissors, lizard, or spock: ").lower()
9+
return user_choice
10+
11+
12+
def get_computer_choice():
13+
return random.choice(choices)
14+
15+
16+
def determine_winner(user_choice, computer_choice):
17+
win_conditions = {
18+
"scissors": ["paper", "lizard"],
19+
"paper": ["rock", "spock"],
20+
"rock": ["lizard", "scissors"],
21+
"lizard": ["spock", "paper"],
22+
"spock": ["scissors", "rock"]
23+
}
24+
25+
if user_choice == computer_choice:
26+
return "tie"
27+
elif computer_choice in win_conditions[user_choice]:
28+
return "user"
29+
else:
30+
return "computer"
31+
32+
33+
def play_game():
34+
print("Welcome to Rock, Paper, Scissors, Lizard, Spock!")
35+
36+
while True:
37+
while True:
38+
try:
39+
num_rounds = int(input("Enter the number of rounds you want to play: "))
40+
if num_rounds <= 0:
41+
print("Please enter a positive number.")
42+
continue
43+
break
44+
except ValueError:
45+
print("Invalid input. Please enter a number.")
46+
47+
user_score = 0
48+
computer_score = 0
49+
ties = 0
50+
51+
for round_number in range(1, num_rounds + 1):
52+
print(f"\nRound {round_number}/{num_rounds}")
53+
54+
user_choice = get_user_choice()
55+
computer_choice = get_computer_choice()
56+
57+
print(f"\nYou chose: {user_choice}")
58+
print(f"Computer chose: {computer_choice}")
59+
60+
winner = determine_winner(user_choice, computer_choice)
61+
62+
if winner == "tie":
63+
print("It's a tie!")
64+
ties += 1
65+
elif winner == "user":
66+
print("You win!")
67+
user_score += 1
68+
else:
69+
print("Computer wins!")
70+
computer_score += 1
71+
72+
print(f"\nScores:\nUser: {user_score}\nComputer: {computer_score}\nTies: {ties}")
73+
74+
print("\nFinal Scores:")
75+
print(f"User: {user_score}")
76+
print(f"Computer: {computer_score}")
77+
print(f"Ties: {ties}")
78+
79+
while True:
80+
play_again = input("\nDo you want to play again? (y/n): ").lower()
81+
if play_again in ["y", "n"]:
82+
break
83+
print("Invalid input. Please enter 'y' or 'n'.")
84+
85+
if play_again != "y":
86+
print("Thanks for playing!")
87+
break
88+
89+
if __name__ == "__main__":
90+
play_game()

0 commit comments

Comments
 (0)