Skip to content

Instantly share code, notes, and snippets.

@ansakoy
Created June 30, 2013 13:20
Show Gist options
  • Save ansakoy/5895123 to your computer and use it in GitHub Desktop.
Save ansakoy/5895123 to your computer and use it in GitHub Desktop.
Homework 1 for 6.189 A Gentle Introduction to Programming (within Python mechanical MOOC), Week 2
print '***ROCK PAPER SCISSORS***'
pl1 = raw_input("Enter Player 1's choice (rock, paper or scissors): ")
pl1 = pl1.lower() # convert input into lower case
# Making sure the input is valid
if pl1 == 'rock' or pl1 == 'paper' or pl1 == 'scissors':
print 'Player 1: ' + pl1
else:
print 'Invalid input'
pl2 = raw_input("Enter Player 2's choice: ")
pl2 = pl2.lower() # convert input into lower case
# Making sure the input is valid
if pl2 == 'rock' or pl2 == 'paper' or pl2 == 'scissors':
print 'Player 2: ' + pl2
else:
print 'Invalid input'
if pl1 == 'rock' and pl2 == 'rock':
print 'Tie'
elif pl1 == 'rock' and pl2 == 'scissors':
print 'Player 1 wins'
elif pl1 == 'rock' and pl2 == 'paper':
print 'Player 2 wins'
elif pl1 == 'paper' and pl2 == 'rock':
print 'Player 1 wins'
elif pl1 == 'paper' and pl2 == 'scissors':
print 'Player 2 wins'
elif pl1 == 'paper' and pl2 == 'paper':
print 'Tie'
elif pl1 == 'scissors' and pl2 == 'rock':
print 'Player 2 wins'
elif pl1 == 'scissors' and pl2 == 'scissors':
print 'Tie'
elif pl1 == 'scissors' and pl2 == 'paper':
print 'Player 1 wins'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment