In the game Rock Paper Scissors, two players simultaneously choose one of the three options: rock, paper, scissors. If both player choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows:
• Rock beats scissors, because a rock can break a pair of scissors
• Scissors beats paper, because scissors can cut paper
• Paper beats rock, because a piece of paper can cover a rock
Create a Python script in which a computer randomly choose
rock, paper or scissors. Let the user enter a number 1, 2, or 3 each
representing one of the three choices. Then, determine the winner.
I need the code to have an output stated above.
import random
print('1 Rock')
print('2 Paper')
print('3 Scissors')
print(' Your choise:')
computer = random.randint(1, 3)
player = int(input())
if player == computer:
print('Draw')
elif player in [1, 2, 3]:
if player == 1 && computer == 3 || player == 3 && computer == 2 || player == 2 && computer == 1:
print('You won')
else
print('You lose')
else:
print('Invalid choise')
Comments
Leave a comment