• API
• FAQ
• Tools
• Trends
• Archive
SHARE
TWEET

# MechMOOC WK2 (6.189 1.7)

Neec0 Jul 10th, 2013 22 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. # Exercise 1.7
2. # Rock Paper Scissor
3. # Collaborators: None
4. # Time Spent:
5.
6. #Begin Game
7. print "Welcome to a game of Rock, Paper, Scissor!  Please choose one of the \
8. following: Rock, Paper, or Scissor."
9. def rps():
10.     count = 0
11.     while count < 3:
12.         #Player Input
13.         p1 = raw_input("Player 1, choose your weapon!: ").lower()
14.
15.         p2 = raw_input("Player 2, choose your weapon!: ").lower()
16.
17.         #P1 Rock
18.         if p1 == "rock" and p2 == "rock":
19.             print "TIE!"
20.             count += 1
21.
22.         elif p1 == "rock" and p2 == "paper":
23.             print "Player 2 Wins!"
24.             count += 1
25.
26.         elif p1 == "rock" and p2 == "scissor":
27.             print "Player 1 Wins!"
28.             count += 1
29.
30.         #P1 Paper
31.         elif p1 == "paper" and p2 == "paper":
32.             print "TIE!"
33.             count += 1
34.
35.         elif p1 == "paper" and p2 == "rock":
36.             print "Player 1 Wins!"
37.             count += 1
38.
39.         elif p1 == "rock" and p2 == "scissor":
40.             print "Player 2 Wins!"
41.             count += 1
42.
43.         #P1 Scissor
44.         elif p1 == "scissor" and p2 == "scissor":
45.             print "TIE!"
46.             count += 1
47.
48.         elif p1 == "scissor" and p2 == "rock":
49.             print "Player 2 Wins!"
50.             count += 1
51.
52.         elif p1 == "scissor" and p2 == "paper":
53.             print "Player 1 Wins!"
54.             count += 1
55.
56.         else:
57.             print "Invalid selection"
58.
59. rps()
RAW Paste Data
Top