Write a program that allows a user to play 5 rounds of Rock Paper Scissors against a
Fantastic news! We've Found the answer you've been seeking!
Question:
Expert Answer:
Answer rating: 100% (QA)
Python Programming Code to copy Importing a random module import random Variable to store player wins count userwins 0 Loop to simulate 5 rounds for i in range1 6 Printing current round number printRoundi Taking input for player choice userchoice intinputEnter your choice1Rock 2Paper 3Scissors Loop to validate user input while userchoice not in 123 userchoice intinputInvalid choice 1 2 or 3 Generating computer choice computerchoice randomchoiceRock Paper Scissors Printing computer choice printComputer chose computerchoice Based on user choice finding who won and incrementing player wins if userchoice 1 if computerchoice Rock printThe round is a draw elif computerchoice Paper printPaper beats Rock Computer wins else printRock beats Scissors Player wins userwins 1 elif userchoice 2 if computerchoice Paper printThe round is a draw elif computerchoice Rock printPaper beats Rock Player wins userwins 1 else printScissors beats Paper Computer wins else if computerchoice Scissors printThe round is a draw elif computerchoice Paper printScissors beats Paper Player wins userwins 1 else printRock beats Scissors Computer wins printYou have wonuserwinsofirounds Calculating player win ... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Write a program that allows the user to compute the remainder after the division of two integer values. The remainder of x/y is x%y. Catch any exception thrown and allow the user to enter new values.
-
Write a program that allows the user to play "Rock, Paper, Scissors". Write the RPS class. All code should be in one file. main() will be part of the RPS class, fairly small, and contain only a loop...
-
Write a program that allows the user to enter his or her name. The program should output a username for entry into a website. The user should be prompted to enter a first name, middle initial, and...
-
If the molecular weight of air is 28.9, what is the density of air at atmospheric pressure and a temperature of 328.2 K? 1 atm = 1.013 x 10 5 N/m, the mass of a proton is 1.67262 x 10 -27 kg,...
-
To what extent should the liquidity measures revisions be considered if LIFO were to be eliminated from U.S. GAAP? Provide examples of those likely measures that would be affected.
-
To cool a summer home without using a vapor-compression refrigeration cycle, air is routed through a plastic pipe (k = 0.15 W/m K, Di = 0.15 m, Do = 0.17 m) that is submerged in an adjoining body of...
-
Consider the following cash flow profile and assume MARR is 10 percent/year. a. Determine the ERR for this project. b. Is this project economically attractive? EOY 0 2 3 4 5 6 NCF -$100 $15 $15 $15...
-
The comparative balance sheet of Rowe Products Inc. for December 31, 2013 and 2012, is as follows: The income statement for the year ended December 31, 2012, is as follows: The following additional...
-
Need a positive comment and some additional comment for the following post from Janet a classmate?Determine if you would be eligible for Medicaid in the state where you live. If not, how much less...
-
Mr. M has been employed as an engineer by A Ltd., a company incorporated in Hong Kong. During the year ended 31 March 2019, Mr. M had the following income and expenditure. A monthly salary of...
-
The following government bond is traded on the stock exchange: Face value= 4,000 Coupon rate=3.% Time to maturity=4 years Yield to maturity 1.2% What is the fair price of bond in %?
-
Describe the performance measures used on the Job-floor level to measure the performance of an organization.
-
Suppose ABC Co . issues $ 2 8 . 4 5 million of 2 9 year zero coupon bonds today. If investors require a return of 6 . 2 3 percent compounded semiannually and all the bonds remain outstanding until...
-
Description of Your Integrated Change Control Process: Your assignment should describe an integrated change control process. Imagine that you have completed evaluating the project, and it is clear...
-
Describe the Control Scope process, its inputs, tools, techniques and outputs. explain Control scope management its inputs, tools, techniques and outputs.
-
Why would the diversity of languages spoken by persons within the healthcare workforce create teamwork problems among healthcare staff? What language etiquette could ease interpersonal and...
-
Discuss Neoclassicism in the artwork "Jean-Auguste Dominique Ingres. Jupiter and Thetis." Discuss Romanticism in the artwork "Eugne Delacroix. The Women of Algiers. 1834." Discuss Realism in the...
-
Create an appropriate display of the navel data collected in Exercise 25 of Section 3.1. Discuss any special properties of this distribution. Exercise 25 The navel ratio is defined to be a persons...
-
Using synchronization, correct the problem in the preceding exercise so that the second thread does not throw a ConcurrentModificationException.
-
Write a program that reads a Celsius degree in a double value from the console, then converts it to Fahrenheit and displays the result. The formula for the conversion is as follows: fahrenheit = (9 /...
-
Rewrite Listing 2.10, ComputeChange. java, to fix the possible loss of accuracy when converting a float value to an int value. Read the input as a string such as "11.56". Your program should extract...
-
The following table shows the interest rates on the fixed and floating borrowing choices available to three firms. Firms A and B want to be exposed to a floating interest rate while Firm C would...
-
Futures contracts are standardized contracts for the delivery of a specified quantity of a commodity or financial instrument on a prearranged future date, at an agreed- upon price. They are a bet on...
-
Derivatives transfer risk from one person or firm to another. They can be used in any combination to unbundle risks and resell them.
Study smarter with the SolutionInn App