-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrcp_test.py
More file actions
112 lines (52 loc) · 1.56 KB
/
Copy pathrcp_test.py
File metadata and controls
112 lines (52 loc) · 1.56 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import random
"""
========
Rock scissors paper games
========
play rock scissors paper games 10 times and terminate.
"""
play = True
i = 0
while play :
#player_choice
player = input("Enter your choice (rock/paper/scissors): ")
player = player.lower()
while (player != "rock" and player != "paper" and player != "scissors"):
player = input("Enter your choice (rock/paper/scissors): ")
player = player.lower()
#computer_random
computer = random.randint(1,3) #random number generate
if (computer == 1): #case of computer
computer = "rock"
elif (computer == 2):
computer = "paper"
elif (computer == 3):
computer = "scissors"
else:
print ("Error. Enter your choice from rock, paper, scissors.")
print ("computer : " + computer);
#result
if (player == computer): #case of result
print ("Draw!")
elif (player == "rock"):
if (computer == "paper"):
print ("You lost.");
if (computer == "scissors"):
print ("You won.");
elif (player == "paper"):
if (computer == "rock"):
print ("You won.");
if (computer == "scissors"):
print ("You lost.");
elif (player == "scissors"):
if (computer == "rock"):
print ("You lost.");
if (computer == "paper"):
print ("You won.");
i = i + 1
#define end condition
if (i >= 10):
play = False
print ("See you again.")
else:
play = True