-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stone_paper_scissor_game.py
72 lines (49 loc) · 1.84 KB
/
Stone_paper_scissor_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
import random
ai = ["stone", "paper", "scissor"]
print("/*RULES FOR THE GAME*/")
print("You have 3 chances.")
print("You Score will show at the end of the game")
print("Enter the key for corresponding choice :\n\t1. s --> stone\n\t2. p --> paper\n\t3. sc --> scissor")
lose = 1
score = 0
while True:
if lose == 3:
break
ai_choice = ai[random.randint(0, 2)]
user_choice = input("Enter your choice : ")
print()
if ai_choice == 'stone':
if user_choice == 's':
print("Computer choice : Stone\nYour choice : Stone\nMatch Draw!!")
elif user_choice == 'sc':
print("Computer choice : Stone\nYour choice : Scissor\nComputer Wins!!")
lose += 1
elif user_choice == 'p':
print("Computer choice : Stone\nYour choice : Paper\nYou Wins!!")
score += 10
else:
print("Invalid choice")
elif ai_choice == 'paper':
if user_choice == 's':
print("Computer choice : Paper\nYour choice : Stone\nComputer Wins!!")
lose += 1
elif user_choice == 'sc':
print("Computer choice : Paper\nYour choice : Scissor\nYou Wins!!")
score += 10
elif user_choice == 'p':
print("Computer choice : Paper\nYour choice : Paper\nMatch Draw!!")
else:
print("Invalid choice")
else:
if user_choice == 's':
print("Computer choice : Scissor\nYour choice : Stone\nYou Wins!!")
score += 10
elif user_choice == 'sc':
print("Computer choice : Scissor\nYour choice : Scissor\nMatch Draw!!")
elif user_choice == 'p':
print("Computer choice : Scissor\nYour choice : Paper\nComputer Wins!!")
score += 10
else:
print("Invalid choice")
print()
print("Total Score :", score)