Assignment
Assignment 2.2
Assignment 2.2
Completion requirements
Opened: Saturday, 13 May 2017, 12:00 AM
Write a program that plays rock, paper, scissors
- Create a program that randomly prints 0, 1, or 2.
- Expand the program so it randomly prints rock, paper, or scissors using if statements.
- Add to the program so it first asks the user their choice. (It will be easier if you have them enter 1, 2, or 3.)
- Add conditional statement to figure out who wins.
The following is a sample code to start with. It is not the best code for solving the game but it is very analytic and understandable.
import random user = int(input("Select Rock:1, Paper:2 or Scissors:3 : ")) if user == 1: print("User selected Rock") elif user == 2: print("User selected Paper") else: print("Usel selected Scissors") comp = random.randint(1,3) if comp == 1: print("Computer selected Rock") elif comp == 2: print("Computer selected Paper") else: print("Computer selected Scissors") if comp == user: print ("It is a tie") elif user == 1 and comp == 3: print("User Wins") # add the other cases #elif #else: