Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This is a simple paper, rock, scissors game, where the players
- #enter one of those three options, and the program determines which is the
- #winner, with the rules of "paper beats scissors, scissors beats paper,
- #and paper beats rock".
- #THe following two lines sets the values of "value1" and "value2" to 0. These are the strings
- #that will allow us to compare the input from player one to player2
- value1=0
- value2=0
- #this is the instruction that takes input from player 1 and translates it
- #to an integer value, which allows us to compare it to player 2 (I think the
- #previous 3 lines of code aren't necessary, but hey, they're in there.
- player1=raw_input("Player 1, enter 'rock' 'paper' or 'scissors': ")
- if player1 == "rock":
- value1=3
- elif player1 == "scissors":
- value1=2
- elif player1 == "paper":
- value1=1
- #This tells the player if they didn't enter a valid option for their input
- else:
- print "You didn't enter a valid object."
- #This is the same as for player one, it just assigns the value of
- #rock, etc, to "value2"
- player2=raw_input("Player 2, enter 'rock' 'paper' or 'scissors': ")
- if player2 == "rock":
- value2=3
- elif player2 == "scissors":
- value2=2
- elif player2 == "paper":
- value2=1
- else:
- print "You didn't enter a valid object."
- #next, we assign a function to compare value1 to value2 (I think
- #you really don't need this as a function, but i like functions.
- def testvalue(value1, value2):
- if value1==3 and value2==1:
- print "Player 2 wins."
- elif value1==1 and value2==3:
- print "Player 1 wins."
- elif value1==value2:
- print "Tie."
- elif value1 > value2:
- print "Player 1 wins."
- elif value2 > value1:
- print "Player 2 wins."
- #then we run the function, with value1 and value2
- testvalue(value1, value2)
Add Comment
Please, Sign In to add comment