-
Notifications
You must be signed in to change notification settings - Fork 0
/
RockPaperScissorsGame.py
58 lines (45 loc) · 1.76 KB
/
RockPaperScissorsGame.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
import random
import time
user_wins = 0
computer_wins = 0
draw = 0
age = 12
options = ["rock","paper","scissors"]
while True:
computerChoice = random.randint(0, 2)
user_input = input("Type Rock, Paper or Scissors. Q to quit: ")
if (user_input == "q"):
break
if (user_input not in options):
continue
#rock is 0, paper is 1 and scissors is 2
#random_no is an interger between 0 and 2. And options has elements between 0 and 2
#by setting a variable equal to options and random number, then we get a computer guessor
computer_guess = options[computerChoice]
print("Computer picked: ", computer_guess, ".")
if (user_input == "rock" and computer_guess) == "scissors":
print("You won!")
user_wins += 1
print("You currently have ",user_wins,". Computer has ",computer_wins)
elif (user_input == "paper" and computer_guess) == "rock":
print("You won!")
user_wins += 1
print("You currently have ",user_wins,". Computer has ",computer_wins)
elif (user_input == "scissors" and computer_guess) == "paper":
print("You won!")
user_wins += 1
print("You currently have ",user_wins,". Computer has ",computer_wins)
elif (user_input == computer_guess):
print("Draw!")
print("You currently have ",user_wins,". Computer has ",computer_wins)
else:
print("You Lost!")
computer_wins += 1
print("You currently have ",user_wins,". Computer has ",computer_wins)
print("You won" , user_wins, "times while computer won", computer_wins, "times")
if(user_wins > computer_wins):
print("Welldone champion")
elif(user_wins == computer_wins):
print("Good game for you both")
else:
print("Better luck next time")