Answered step by step
Verified Expert Solution
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 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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started