1+ # Welcome the user to the game:
2+ print ("+---------------------------------------------+" )
3+ print ("| Welcome to the Rock, Papers, Scissors Game! |" )
4+ print ("+---------------------------------------------+" )
5+
6+ import random
7+
8+ user_wins = 0
9+ computer_wins = 0
10+ options = ['r' , 'p' , 's' ]
11+ opt = ['Rock' , ' Paper' , 'Scissors' ]
12+
13+ while True :
14+ print ("\n +----------------------------------+" )
15+ user_input = int (input ("| Choose any number for your Pick: |\n +----------------------------------+\n | 0: Rock \
16+ |\n | 1: Paper |\n | 2: Scissors |\n | 3: Quit |\n +----------------------------------+\n Your Choice: " ))
17+ if (user_input < 3 ):
18+ # Assigning and Comparing the user and computer inputs.
19+ random_number = random .randint (0 ,2 )
20+ computer_pick = options [random_number ]
21+ user_pick = options [user_input ]
22+ print (f"You have picked: { opt [user_input ]} ." )
23+ print (f"Computer picked: { opt [random_number ]} ." )
24+
25+ if (computer_pick == user_pick ):
26+ print ("Round Tied.\n " )
27+ elif (user_pick == 'r' ) & (computer_pick == 's' ):
28+ print ("You won the round!\n " )
29+ user_wins += 1
30+ elif (user_pick == 'p' ) & (computer_pick == 'r' ):
31+ print ("You won the round!\n " )
32+ user_wins += 1
33+ elif (user_pick == 's' ) & (computer_pick == 'p' ):
34+ print ("You won the round!\n " )
35+ user_wins += 1
36+ else :
37+ print ("You Lost the round." )
38+ computer_wins += 1
39+ print ("+--------------------------------------+" )
40+ print (f"| Your Score: { user_wins } | Computer's Score: { computer_wins } |" )
41+ print ("+--------------------------------------+" )
42+
43+ elif (user_input == 3 ):
44+ print ("+--------------------------------------+" )
45+ print (f"| Your Score: { user_wins } | Computer's Score: { computer_wins } |" )
46+ print ("+--------------------------------------+" )
47+ print ("\n GoodBye!\n " )
48+ quit ()
49+ else :
50+ print ('Invalid Choice! Choose a proper valid option.\n ' )
51+ continue
0 commit comments