-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4. Rock, Paper, Scissors Game.py
89 lines (75 loc) · 1.56 KB
/
4. Rock, Paper, Scissors Game.py
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
# Rock, Paper, Scissors Game
import random
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
game = [rock, paper, scissors]
user_choice = int(input("enter your choice: 0 for rock, 1 for paper, 2 for scissor: "))
print(game[user_choice])
computer_choice = random.randint(0,2)
if user_choice == 0 and computer_choice == 2:
print(f"computer choice: {game[computer_choice]}")
print("you won")
elif user_choice == 1 and computer_choice == 0:
print(f"computer choice: {game[computer_choice]}")
print("you won")
elif user_choice == 2 and computer_choice == 1:
print(f"computer choice: {game[computer_choice]}")
print("you won")
else:
print(f"computer choice: {game[computer_choice]}")
print("computer won")
# Output:
Sample - 1
enter your choice: 0 for rock, 1 for paper, 2 for scissor: 0
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
computer choice:
_______
---' ____)____
______)
_______)
_______)
---.__________)
computer won
Sample -2:
enter your choice: 0 for rock, 1 for paper, 2 for scissor: 2
_______
---' ____)____
______)
__________)
(____)
---.__(___)
computer choice:
_______
---' ____)____
______)
_______)
_______)
---.__________)
you won