Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program (rockpaperscissors.py) that does the following: Import the random module into your program Write a function called computer RPS () that

Write a Python program (rockpaperscissors.py) that does the following:  Import the random module into your

Write a Python program (rockpaperscissors.py) that does the following: Import the random module into your program Write a function called computer RPS () that uses the random number generator to return one of "rock", "paper", or "scissors" In the main () function, print a velcome message to the user Ask the user for their choice - rock/paper/scissors. Perform input validation and only accept valid input. Call the computeRPS () function and save the returned "computer's choice" value in a variable Display the user's choice and the computer's choice. Now as per the rules of the game, display whether the player or the computer is the winner. The rules are as follows: 1. If both the computer and the player pick the same (rock/paper/scissors), it is a tie. 2. Rock beats scissors. 3. Paper beats rock 4. Scissors beat paper Based on the rules mentioned above, determine whether it is a tie, or whether the computer won or whether the player won and display a message accordingly. Ask the user if s/he wants to play again and go back to the beginning if the user enters a 'y' or 'Y'. Perform input validation for the yes/no option.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

import random def computerRPS Returns a random choice of rock paper or scissors choice randomchoicer... 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

Step: 3

blur-text-image

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

Principles Of Information Security

Authors: Michael E. Whitman, Herbert J. Mattord

7th Edition

035750643X, 978-0357506431

More Books

Students also viewed these Programming questions

Question

4. How does a sex-linked gene differ from a sex-limited genepg78

Answered: 1 week ago