Rock, Paper, Scissors
Rock, Paper, Scissors, Shoot!
Rock, Paper, Scissors, Shoot!
Overview
Overview
Random Library
Random Library
Variables
Variables
Conditional Statements
Conditional Statements
Function
Function
While Loop
While Loop
Program
Program
import random
print('Rock, Paper, Scissors, Shoot!')
def who_won(userPick, comPick):
print('Computer Picked:',comPick)
if userPick == 'Rock' and comPick == 'Rock':
print('Tie')
return 'Tie'
elif userPick == 'Rock' and comPick == 'Paper':
print('You Lose')
return 'Lose'
elif userPick == 'Rock' and comPick == 'Scissors':
print('You Win')
return 'Win'
elif userPick == 'Paper' and comPick == 'Rock':
print('You Win')
return 'Win'
elif userPick == 'Paper' and comPick == 'Paper':
print('Tie')
return 'Tie'
elif userPick == 'Paper' and comPick == 'Scissors':
print('You Lose')
return 'Lose'
elif userPick == 'Scissors' and comPick == 'Rock':
print('You Lose')
return 'Lose'
elif userPick == 'Scissors' and comPick == 'Paper':
print('You Win')
return 'Win'
elif userPick == 'Scissors' and comPick == 'Scissors':
print('Tie')
return 'Tie'
userPoints = 0
comPoints = 0
while True:
print('==================================')
userPick = input('Rock, Paper, or Scissors?')
comPick = random.choice(['Rock', 'Paper', 'Scissors'])
result = who_won(userPick, comPick)
if result == 'Win':
userPoints += 1
elif result == 'Lose':
comPoints += 1
print('User:', userPoints, 'Computer:', comPoints)