Skip to content

Commit 0a2d0a2

Browse files
Rock Paper Scissors game eventually to be done in class
1 parent 676fe71 commit 0a2d0a2

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

rps.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
'''
2+
Made by Christopher Geiger on 10/19/2016
3+
Created for educational purposes
4+
'''
5+
6+
7+
8+
# Welcomes user
9+
# Get user input
10+
# Calculate computer's throw
11+
# Resolve situation (who wins, is there a tie)
12+
# Loop
13+
14+
import random
15+
16+
def welcome():
17+
print('Welcome to RPS!')
18+
print('Please choose a move:')
19+
print('Rock - 1\nPaper - 2\nScissors - 3')
20+
21+
def getCompThrow():
22+
print("Getting the computer's throw...")
23+
compThrow = random.randint(1,3)
24+
print("The computer threw a ", end='')
25+
26+
if(compThrow == 1):
27+
print('rock!')
28+
elif(compThrow == 2):
29+
print('paper!')
30+
else:
31+
print('scissor!')
32+
33+
return compThrow
34+
35+
def resolve(uThrow, cThrow):
36+
if(uThrow == cThrow):
37+
print('There has been a tie!')
38+
elif(uThrow == 1 and cThrow == 2):
39+
print('You lost!')
40+
elif(uThrow == 2 and cThrow == 3):
41+
print('You lost!')
42+
elif(uThrow == 3 and cThrow == 1):
43+
print('You lost!')
44+
else:
45+
print('You won!')
46+
47+
def clear():
48+
print('\n' * 100)
49+
50+
while True:
51+
clear()
52+
welcome()
53+
usrThrow = int(input())
54+
resolve(usrThrow, getCompThrow())
55+
print('Play again? Y/N')
56+
if(input().lower() != 'y'):
57+
break

0 commit comments

Comments
 (0)