Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c8b906f

Browse files
Add "Rock, Paper and Scissors" example
Signed-off-by: Ercan Ersoy <ercanersoy@ercanersoy.net>
1 parent be89979 commit c8b906f

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

‎rock-paper-scissors/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Rock, paper, Scissors
2+
3+
A rock, paper, scissors game program
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from random import uniform
2+
3+
elements = ["rock", "paper", "scissors"]
4+
5+
print("1) Rock")
6+
print("2) Paper")
7+
print("3) Scissors")
8+
print()
9+
10+
player_choice = int(input("Your choice: "))
11+
computer_choice = int(uniform(1, 3))
12+
13+
print("Player's choice: ", end="")
14+
print(elements[player_choice - 1])
15+
print()
16+
17+
print("Computer's choice: ", end="")
18+
print(elements[computer_choice - 1])
19+
print()
20+
21+
if (player_choice == computer_choice):
22+
print("This game is draw.")
23+
elif (player_choice == 1):
24+
if (computer_choice == 2):
25+
print("You lose.")
26+
else:
27+
print("You win.")
28+
elif (player_choice == 2):
29+
if (computer_choice == 3):
30+
print("You lose.")
31+
else:
32+
print("You win.")
33+
elif (player_choice == 3):
34+
if (computer_choice == 1):
35+
print("You lose.")
36+
else:
37+
print("You win.")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /