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 computerRPS) that uses the random

image text in transcribed
Write a Python program (rockpaperscissors.py) that does the following: Import the random module into your program Write a function called computerRPS) 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 yeso option

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

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

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions

Question

7. Determine what feedback is provided to employees.

Answered: 1 week ago