File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ import random
2
+
3
+ print ("Welcome to the Stone, Paper, Scissor Game" )
4
+
5
+ # User choise
6
+ while True :
7
+ wincom = 0
8
+ winuser = 0
9
+ for i in range (1 , 6 ):
10
+ print ("\n Round" , i , "Start" )
11
+ user = input ("1) Stone\n 2) Paper\n 3) Scissor\n Choose one option: " )
12
+ if user == "stone" :
13
+ print ("You selected Stone" )
14
+ elif user == "paper" :
15
+ print ("You selected Paper" )
16
+ elif user == "scissor" :
17
+ print ("You selected Scissor" )
18
+ else :
19
+ exit ("Program Failed" )
20
+ break
21
+
22
+ # Computer choise
23
+ computer = random .choice (["Stone" , "Paper" , "Scissor" ])
24
+ print ("Computer selected" , computer )
25
+ if (user == "stone" and computer == "Paper" ) or (user == "paper" and computer == "Scissor" ) or (user == "scissor" and computer == "Stone" ):
26
+ print ("Computer won!" )
27
+ wincom += 1
28
+ elif (user == "stone" and computer == "Scissor" ) or (user == "paper" and computer == "Stone" ) or (user == "scissor" and computer == "Paper" ):
29
+ print ("You won!" )
30
+ winuser += 1
31
+ elif (user == "stone" and computer == "Stone" ) or (user == "paper" and computer == "Paper" ) or (user == "scissor" and computer == "Scissor" ):
32
+ print ("It's a draw!" )
33
+ else :
34
+ print ("Program Failed" )
35
+
36
+ if wincom > winuser :
37
+ print (f"\n Match Over\n You Lose!\n Scores: Computer { wincom } Your { winuser } " )
38
+ elif wincom < winuser :
39
+ print (f"\n Match Over\n You won!\n Scores: Computer { wincom } Your { winuser } " )
40
+ elif wincom == winuser :
41
+ print (f"\n Match Over\n It's a draw!\n Scores: Computer: { wincom } , You: { winuser } " )
42
+ user_choise = input ("\n Play Again? (Yes/Exit): " )
43
+ if user_choise == 'yes' :
44
+ continue
45
+ else :
46
+ break
You can’t perform that action at this time.
0 commit comments