Rock Paper Scissors
if, elif, and else plus CONDITIONALS and booleans
Do after Conditionals and Control Flow in Codecademy
Do after Conditionals and Control Flow in Codecademy
Rock Paper Scissors Game
import random
#Ask the user to choose rock, paper, or scissors.
choice = raw_input("Do you choose rock, paper, or scissors?")
#Have the computer calculate a random choice.
rps = random.randint(0,2)
### Compare the two choices using if computerchoice ==playerschoice:
and print result including whether it was a tie, victory, or loss.
Rubric:
Must be fair so use random.randint()
Spell correctly!
No errors in code
Must work for entire game
Use Codecademy if you want extra help, but try it alone first:
https://www.codecademy.com/courses/python-intermediate-en-t5dl0/0/1#
Extra HINTS:
Repeat the game over and over with a while loop:
#Here is the while loop, which will continue till break. The below text is intended to fit into the while loop.
while 1:
# put code here.
#Make sure if you are comparing numbers, the type is int:
whatevertheuserchooses = int(raw_input("Choose 1 for rock, 2 for paper, and 3 for scissors."))
Upper and lower case responses
x = x.upper()
x = x.lower()
documentation: https://docs.python.org/2/library/string.html#string.lower
import random
#Ask the user to choose rock, paper, or scissors.
choice = raw_input("Do you choose rock, paper, or scissors?")
#Have the computer calculate a random choice.
rps = random.randint(0,2)
### Compare the two choices using if computerchoice ==playerschoice:
and print result including whether it was a tie, victory, or loss.
Rubric:
Must be fair so use random.randint()
Spell correctly!
No errors in code
Must work for entire game
Use Codecademy if you want extra help, but try it alone first:
https://www.codecademy.com/courses/python-intermediate-en-t5dl0/0/1#
Extra HINTS:
Repeat the game over and over with a while loop:
#Here is the while loop, which will continue till break. The below text is intended to fit into the while loop.
while 1:
# put code here.
#Make sure if you are comparing numbers, the type is int:
whatevertheuserchooses = int(raw_input("Choose 1 for rock, 2 for paper, and 3 for scissors."))
Upper and lower case responses
x = x.upper()
x = x.lower()
documentation: https://docs.python.org/2/library/string.html#string.lower