Write a program that lets the user play a game of Rock, Paper, Scissors against the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that lets the user play a game of Rock, Paper, Scissors against the computer. The program should work as follows: 1. When the program begins, the computer chooses either 'rock', 'paper, or 'scissors' at random. (Don't display the computer's choice yet.) This step should be implemented using a function named get_computer_choice that takes no arguments and returns the computer's choice as a string, either 'rock', 'paper, or 'scissors'. 2. Then the user is asked to make their choice, either 'rock', 'paper, or scissors. If the user enters an invalid choice they should be asked to try again until they enter a valid choice. This step should be implemented using a function named get_player_choice that takes no arguments and returns the player's valid choice as a string, either 'rock', 'paper', or 'scissors. 3. Once both players have chosen, their choices are displayed. 4. Next a winner is selected according to the following rules: • If one player chooses rock and other player chooses scissors, then rock wins (rock smashes scissors). • If one player chooses scissors and the other player choose paper, then scissors wins (scissors cut paper). • If one player chooses paper and the other play chooses rock, then paper wins (pa- per wraps rock). • If both players make the same choice, the game is played again to determine the winner. This step should be implemented using a function named get_winner that takes the computer's choice as its first argument, and the player's choice as its second argument. Both arguments should be strings. The function should return the winner as a string, either 'computer', 'player', or 'tie'. 5. Finally, the program should display the results of the contest. If it is a tie, the match should continue until one player wins. Test your program at least 3 times and take the screenshot of all the results. Include at least one invalid user choice, one rock, one paper, and one scissor in your test. A sample of the output is shown below. Your program should match the formatting of the sample but your results will be different because the computers choices should be generated randomly. User input in the sample has been highlighted in Pappy's Purple to distinguish it from the program's output, but your user input does not need to be colored. Save your program as rock_paper_scissors_login.py, where login is your Purdue login. Then submit it along with a screenshot showing all 4 test conditions. Terminal $ python rock_paper_scissors_login.py Choose rock, paper, or scissors: papper You made an invalid choice. Please try again. Choose rock, paper, or scissors: rock The computer chose paper, and you chose rock. paper beats rock You lost. Better luck next time. Thanks for playing. $ python rock_paper_scissors_login.py Choose rock, paper, or scissors: paper The computer chose rock, and you chose paper. paper beats rock. You won the game! Thanks for playing. $ python rock_paper_scissors_login.py Choose rock, paper, or scissors: scissors The computer chose scissors, and you chose scissors. It's a tie. Starting over. Choose rock, paper, or scissors: rock The computer chose rock, and you chose rock. It's a tie. Starting over. Choose rock, paper, or scissors: paper The computer chose scissors, and you chose paper. scissors beats paper You lost. Better luck next time. Thanks for playing. Write a program that lets the user play a game of Rock, Paper, Scissors against the computer. The program should work as follows: 1. When the program begins, the computer chooses either 'rock', 'paper, or 'scissors' at random. (Don't display the computer's choice yet.) This step should be implemented using a function named get_computer_choice that takes no arguments and returns the computer's choice as a string, either 'rock', 'paper, or 'scissors'. 2. Then the user is asked to make their choice, either 'rock', 'paper, or scissors. If the user enters an invalid choice they should be asked to try again until they enter a valid choice. This step should be implemented using a function named get_player_choice that takes no arguments and returns the player's valid choice as a string, either 'rock', 'paper', or 'scissors. 3. Once both players have chosen, their choices are displayed. 4. Next a winner is selected according to the following rules: • If one player chooses rock and other player chooses scissors, then rock wins (rock smashes scissors). • If one player chooses scissors and the other player choose paper, then scissors wins (scissors cut paper). • If one player chooses paper and the other play chooses rock, then paper wins (pa- per wraps rock). • If both players make the same choice, the game is played again to determine the winner. This step should be implemented using a function named get_winner that takes the computer's choice as its first argument, and the player's choice as its second argument. Both arguments should be strings. The function should return the winner as a string, either 'computer', 'player', or 'tie'. 5. Finally, the program should display the results of the contest. If it is a tie, the match should continue until one player wins. Test your program at least 3 times and take the screenshot of all the results. Include at least one invalid user choice, one rock, one paper, and one scissor in your test. A sample of the output is shown below. Your program should match the formatting of the sample but your results will be different because the computers choices should be generated randomly. User input in the sample has been highlighted in Pappy's Purple to distinguish it from the program's output, but your user input does not need to be colored. Save your program as rock_paper_scissors_login.py, where login is your Purdue login. Then submit it along with a screenshot showing all 4 test conditions. Terminal $ python rock_paper_scissors_login.py Choose rock, paper, or scissors: papper You made an invalid choice. Please try again. Choose rock, paper, or scissors: rock The computer chose paper, and you chose rock. paper beats rock You lost. Better luck next time. Thanks for playing. $ python rock_paper_scissors_login.py Choose rock, paper, or scissors: paper The computer chose rock, and you chose paper. paper beats rock. You won the game! Thanks for playing. $ python rock_paper_scissors_login.py Choose rock, paper, or scissors: scissors The computer chose scissors, and you chose scissors. It's a tie. Starting over. Choose rock, paper, or scissors: rock The computer chose rock, and you chose rock. It's a tie. Starting over. Choose rock, paper, or scissors: paper The computer chose scissors, and you chose paper. scissors beats paper You lost. Better luck next time. Thanks for playing.
Expert Answer:
Related Book For
Quantitative Methods for Business
ISBN: 978-0840062345
12th edition
Authors: David Anderson, Dennis Sweeney, Thomas Williams, Jeffrey Cam
Posted Date:
Students also viewed these programming questions
-
Should we abolish the minimum wage altogether and let market forces of supply and demand determine equilibrium wages for workers, or should we keep the federal minimum wage at its current levels and...
-
Sep. 25: Sold merchandise inventory to Smith for $ 1 comma 100 on account that cost $ 484. Terms of 2/10, n/30 was offered, FOB shipping point. As a courtesy to Smith, $ 90 of freight was added to...
-
2. Consider a 3-year American call option on a stock which pays dividends in 1 year and 2 years. The first dividend is $5 and the second dividend is $6. The current stock price is $100, the exercise...
-
Determine which of the fundamental laws of algebra is demonstrated. 8(3 2) = 8(3) 8(2)
-
Assume the same system as in the previous problem, but let the piston be locked with a pin. If the water is heated to saturated vapor find the final temperature, volume and the work, 1W2.
-
The following year - end information is taken from the December 3 1 adjusted trial balance and other records of Leone Company. Advertising expense $ 2 8 , 7 5 0 Depreciation expense Office equipment...
-
Distinguish the following data as qualitative and quantitative. Explain why. a. Social Security Number. b. Zip Code. c. Degree of job satisfaction. d. Price. e. Age. f. Effectiveness. g....
-
According to The Wall Street Journal, Mitsubishi Motors recently announced a major restructuring plan in an attempt to reverse declining global sales. Suppose that as part of the restructuring plan...
-
During the spin cycle the time dependent angular speed of a washing machine drum is given by the equation ( t ) = at + bt 2 - ct 4 where a = 2.8 rad/s 2 , b = 0.35 rad/s 3 and c = 0.035 rad/s 5 . At...
-
An accounting entry is required, with one exception: the annual change in employee pay rates, Trans. Document ? Dec. Flowchart Description Received customer purchase order No. 53426 (Doc. No. 4) from...
-
Graph the quadrilateral ABCD if A(-2, 6), B(2,3), C(2,2), and D(-2, 1). A rhombus is a quadrilateral with four congruent sides. Verify that ABCD is a rhombus. a. b. What is the area and perimeter of...
-
What is the worst-case time complexity of building a heap by insertion?
-
What is the worst-case time complexity of finding the largest item in a min-heap?
-
Depreciation information for Corales Company is given in BE9-4. Assuming the declining-balance depreciation rate is double the straight-line rate, compute annual depreciation for the first and second...
-
Ironwood Bank is offering a 30-year mortgage with an APR of 6.10% based on monthly compounding. If you plan to borrow $157,000, what will be your monthly payment?
-
Get in small groups and review the case of Sophia presented earlier in the chapter. Answer the following questions and then share your answers with the class. What communication theory informs...
-
Use the sign chart for y=f(x) below to determine where f(x) > 0 f(x) +++ I Choose all that apply. (-1,1] (-4,-1) O [3,00). 0 (-, -4] O (1,3) 0 [1,3) (-4,-1) (3,00) [-1,1) Und. 1 +++ Und. +++
-
The packaging division of a company having considered several alternative package designs for the company's new product has finally brought down their choices to two designs of which only one has to...
-
Shown is a probability distribution for the random variable x. x f(x) 3 .......0.25 6 ........0.50 9 .......0.25 Total 1.00 a. Compute E(x), the expected value of x. b. Compute 2, the variance of x....
-
Refer again to the data presented in Problem. a. Formulate a linear programming model that can be used to perform data envelopment analysis for hospital E. b. Solve the model. c. Is hospital E...
-
Alexander Industries is considering purchasing an insurance policy for its new office building in St. Louis, Missouri. The policy has an annual cost of $10,000. If Alexander Industries doesn't...
-
Describe the six categories of early warning signs of potential fraud.
-
Identify and describe the key attributes that might mitigate a red flag, suggesting that no bad act or compliance issues exist.
-
FRAUD PREVENTION AND DETERRENCE IN ACTION Assume the following facts: thirty-day collection period. The invoice is used to post-sales to the accounting system. Checks are received in the mailroom and...
Study smarter with the SolutionInn App