Answer to Question #234368 in Python for umesh

Question #234368

Hand game

Abhinav and Anjali are playing Rock-Paper-Scissors game. Rock-Paper-Scissors is a hand game usually played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are "rock", "paper" and "scissors". Based on the shapes the player chooses the outcome of the game is determined. A rock beats scissors, scissors beat paper by cutting it, and paper beats rock by covering it. If the same shape is chosen by both of the players, then it is tie. Write a program to decide the winner of each round of the game based on the shapes the players chose.

Input

The first line of input will be one of the strings "Rock", "Paper", "Scissors", representing the shape chosen by Abhinav. The second line of input will be the sting representing the shape chosen by Anjali..



1
Expert's answer
2021-09-07T23:22:06-0400
Abhinav_choice = str(input ("Abhinav choice:"))
Anjali_choice = str (input ("Anjali choice:"))
if Abhinav_choice == Anjali_choice:
    print ("Tie")
elif Abhinav_choice == "Rock":
    if Anjali_choice == "Paper":
        print ("Player 2 wins")
    else
         print ("Player 1 wins")
elif Abhinav_choice == "Paper":
    if Anjali_choice == "Rock":
         print ("Player 1 wins")
    else:
         print ("Player 2 wins")
elif Anjali_choice == "Rock":
     print ("Player 2 wins")
else:
     print ("Player 1 wins")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS