-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStone Paper Scissor.py
More file actions
50 lines (43 loc) · 1.24 KB
/
Stone Paper Scissor.py
File metadata and controls
50 lines (43 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import random
# Stone Paper Scissor
def gameWin(comp, you):
# If two values are equal, declare a tie!
if comp == you:
return None
# Check for all possibilities when computer chose st
elif comp == 'st':
if you=='sc':
return False
elif you=='p':
return True
# Check for all possibilities when computer chose p
elif comp == 'p':
if you=='st':
return False
elif you=='sc':
return True
# Check for all possibilities when computer chose sc
elif comp == 'sc':
if you=='p':
return False
elif you=='st':
return True
print("Rule: \n 1. Stone wins over Scissor \n 2. Paper wins over Stone \n 3. Scissor wins over Paper")
print("Comp Turn: Stone(st) Paper(p) or Scissior(sc)?")
randNo = random.randint(1, 3)
if randNo == 1:
comp = 'st'
elif randNo == 2:
comp = 'p'
elif randNo == 3:
comp = 'sc'
you = input("Your Turn: Stone(st) Paper(p) or Scissor(sc)?")
a = gameWin(comp, you)
print(f"Computer chose {comp}")
print(f"You chose {you}")
if a == None:
print("The game is a tie!")
elif a:
print("You Win!")
else:
print("You Lose!")