Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python question Rock, Paper, Scissors is a two-player game in which each player chooses one of three items. If both players choose the same item,

Python question

Rock, Paper, Scissors is a two-player game in which each player chooses one of three items. If both players choose the same item, the game is tied. Otherwise, the rules that determine the winner are:

a. b. c.

Rock always beats Scissors (Rock crushes Scissors) Scissors always beats Paper (Scissors cut Paper) Paper always beats Rock (Paper covers Rock)

Implement function rps() that takes the choice ('R', 'P', or 'S') of player 1 and the choice of player 2, and returns -1 if player 1 wins, 1 if player 2 wins, or 0 if there is a tie.

>>> rps('R', 'P') 1 >>> rps('R', 'S') -1

>>> rps('S', 'S') 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions