forked from thisisshub/HacktoberFest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScissorsPaperRock.py
More file actions
97 lines (86 loc) · 2.88 KB
/
ScissorsPaperRock.py
File metadata and controls
97 lines (86 loc) · 2.88 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import random
start = input("Welcome to the game of Scissors, Paper, Rock. Press [Enter} to start.")
outcomes = {
1: "scissors",
2: "paper",
3: "rock"
}
while bool(start) is False:
print("\nYou will play against the computer. Press [Enter] again at anytime to exit the game. Your score will be displayed.")
answer = input("Enter scissors, paper or rock.\n")
i = 0
x = 0
p = 0
a = 0
b = 0
while bool(answer) is True:
while i > 0 and p == 0:
answer = input("")
break
if bool(answer) is False:
break
p = 0
i += 1
answer = answer.lower()
computer = random.randint(1, 3)
computers_answer = outcomes[computer]
if answer == "scissors":
if computers_answer == "scissors":
print(computers_answer)
print("Draw!")
a += 1
elif computers_answer == "paper":
print(computers_answer)
print("You Win!")
x += 1
elif computers_answer == "rock":
print(computers_answer)
print("You Lose!")
b += 1
elif answer == "paper":
if computers_answer == "scissors":
print(computers_answer)
print("You Lose!")
b += 1
elif computers_answer == "paper":
print(computers_answer)
print("Draw!")
a += 1
elif computers_answer == "rock":
print(computers_answer)
print("You Win!")
x += 1
elif answer == "rock":
if computers_answer == "scissors":
print(computers_answer)
print("You Win!")
x += 1
elif computers_answer == "paper":
print(computers_answer)
print("You Lose!")
b += 1
elif computers_answer == "rock":
print(computers_answer)
print("Draw!")
a += 1
elif bool(answer) is False:
break
while answer != "scissors" and answer != "paper" and answer != "rock" and bool(answer) is True:
answer = input("Please enter a valid statement:\n")
p += 1
if bool(answer) is False:
i -= 1
else:
continue
if bool(answer) is False:
break
while True:
try:
z = int(x/i * 100)
a = int(a/i * 100)
b = int(b/i * 100)
print("You have played " + str(i) + " rounds, " + str(x) + " of which you have won! This means you won or drew " + str(z + a) + "%, and lost " + str(b) + "% of the time.")
break
except:
print("You have played " + str(i) + " rounds.")
break