forked from christophergeiger3/sesoProgrammingClub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrps.py
57 lines (46 loc) · 1.23 KB
/
rps.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
'''
Made by Christopher Geiger on 10/19/2016
Created for educational purposes
'''
# Welcomes user
# Get user input
# Calculate computer's throw
# Resolve situation (who wins, is there a tie)
# Loop
import random
def welcome():
print('Welcome to RPS!')
print('Please choose a move:')
print('Rock - 1\nPaper - 2\nScissors - 3')
def getCompThrow():
print("Getting the computer's throw...")
compThrow = random.randint(1,3)
print("The computer threw a ", end='')
if(compThrow == 1):
print('rock!')
elif(compThrow == 2):
print('paper!')
else:
print('scissor!')
return compThrow
def resolve(uThrow, cThrow):
if(uThrow == cThrow):
print('There has been a tie!')
elif(uThrow == 1 and cThrow == 2):
print('You lost!')
elif(uThrow == 2 and cThrow == 3):
print('You lost!')
elif(uThrow == 3 and cThrow == 1):
print('You lost!')
else:
print('You won!')
def clear():
print('\n' * 100)
while True:
clear()
welcome()
usrThrow = int(input())
resolve(usrThrow, getCompThrow())
print('Play again? Y/N')
if(input().lower() != 'y'):
break