Write a Python program (rockpaperscissors.py) that does the following: Import the random module into your...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
import random def computerRPS Returns a random choice of rock paper or scissors choice randomchoicer... View the full answer
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
I. A liquid of density 4.9 103 kg/m3 is contained in a cylinder of negligible mass, base area 0.24 m2 and height of 0.38 m. The liquid completely fills the container. a) What is the volume of the...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
KNO 2 potassium nitrite is a salt that is very soluble in water. Its dissolution forms the species K + and NO 2- . Potassium sulphate (K2SO4) is a salt that is very soluble in water. dissolution...
-
1. You are the audit partner in charge of five audits which have recently been completed. You are reviewing the files and you now only have to decide which form of audit report you will sign off....
-
SaveCo Services, Inc., has $8,600 cash on hand on May 1. The company requires a minimum cash balance of $7,500. May cash collections are $548,480. Total cash payments for May are $563,420. Prepare a...
-
The International Parcel Service has installed a new radio frequency identification system to help reduce the number of packages that are incorrectly delivered. The capital investment in the system...
-
Find the = 0.05 critical value for the chi-square distribution with 18 degrees of freedom.
-
Peak Entertainment acquires 60 percent of its subsidiary Saddlestone Inc. on January 1,2013. In preparing to consolidate Peak and Saddlestone at December 31,2013, we assemble the following...
-
5. Eunice manages a Thai restaurant in a primarily Asian section of a major West Coast city. She is interested in determining dollar sales and number of guests needed to break-even and to generate...
-
The Sally Coffee Shop is considering closing one hour earlier in the evening through the week. Sally obtained the following data from a study taken last week of the number of customers between the...
-
Paper purchased 12,000 of Sands 30,000 shares on 10/1/20X0 for $36,000. At 1/1/20X0, Sand had Common Stock of $30,000 and Retained Earnings of $50,000. During the 12 months ended 12/31/20X0, Sand...
-
Question # 03 A sinusoidal wave traveling to the right along the x-axis with angular frequency w = 2nd, wave number k=2r/A, and amplitude a is (right) =a sin(koxx - wt) An equivalent wave traveling...
-
In retirement, Bill determined that he could safely invest $50,000 into a nonredeemable five-year GIC with a posted rate of 5.35% compounded semi-annually. Calculate the maturity value and the amount...
-
Shannon Company contracts to sell on September 1, 2022 equipment to a German purchaser. The price of the equipment is 200,000 and the bill will be settled in Euros. The future transaction is viewed...
-
A summary of the time tickets is as follows: Job No . Amount Job No . Amount 5 5 $ 3 , 3 0 0 Indirect $ 9 , 3 0 0 5 7 6 , 1 0 5 6 6 9 , 4 3 0 5 8 2 1 , 0 0 5 6 7 1 0 , 0 7 5 6 0 1 5 , 5 0 0...
-
At the beginning of 2025, Cullumber Construction Company changed from the cost-recovery method to recognizing revenue over time (percentage-of-completion) for financial reporting purposes. The...
-
Write the distribution of electrons in carbon and sodium atoms.
-
Consider the activities undertaken by a medical clinic in your area. Required 1. Do you consider a job order cost accounting system appropriate for the clinic? 2. Identify as many factors as possible...
-
I. Detail that friendly departures include resignation, retirement, promotion, or relocation. In this case, the employee may have tendered notice well in advance of the actual departure date. II....
-
Identify that EC Council is a new competitor in certifications for security management. They offer a Certified CISO (CCISO) certification which tests security domain knowledge as well as knowledge of...
-
Explain that the U.S. Computer Emergency Readiness Team (US-CERT) is a division of DHSs National Cybersecurity and Communications Integration Center (NCCIC).
-
Refer to the information in S6-1 . Calculate the gross margin for the month of August. Data from S6-1 Garda's Equipment has the following items in its inventory on August 1: The company uses the...
-
Elmo's Music carries a large inventory of guitars and other musical instruments. The store uses the FIFO method and a perpetual inventory system. Company records indicate the following for a...
-
The account number 211031 most likely refers to a. Liabilities b. Current liabilities c. Accounts payable d. An individual supplier
Study smarter with the SolutionInn App