1- Write a program that simulates a game of dice. In this game, 3 players will...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1- Write a program that simulates a game of dice. In this game, 3 players will take alternate turns rolling two dice. On each turn, they record the sum of the two dice and add this to their total. If a player rolls a doublet (both dice have the same value), then the player gets to roll again. After each turn (when the 3 players roll), the code checks the sum of each player and the player to reach a total of 15 or more will win the first place and the game stops. The code then checks for the second and third place winners. The code will print out to the user the winners in order. If 2 or all the players hit the same sum, you can consider them all first place winners (for example, if player 1 and 2 hit the same sum that's >= 15 and 3rd player hits a sum less than 15, then you can say 1st and 2nd players win first place and 3rd wins second place). For this question, loop(s) and conditionals should be used otherwise you will lose marks. Don't hardcode the output otherwise marks will be deducted. The output should be as follow (note: no user input is required): Player 1 rolls a 1 and a 1 Player 1 now has 2 Player 1 rolls a 6 and a 1 Player 1 now has 9 Player 2 rolls a 3 and a 21 Player 2 now has 5 Player 3 rolls a 5 and a 1 Player 3 now has 6 Player 1 rolls a 4 and a 3 Player 1 now has 16 Player 2 rolls a 6 and a 1 Player 2 now has 12 Player 3 rolls a 6 and a 5 Player 3 now has 17 Player 3 wins the first place with a total of 17 Player 1 wins the second place with a total of 16 Player 2 wins the third place with a total of 12 1- Write a program that simulates a game of dice. In this game, 3 players will take alternate turns rolling two dice. On each turn, they record the sum of the two dice and add this to their total. If a player rolls a doublet (both dice have the same value), then the player gets to roll again. After each turn (when the 3 players roll), the code checks the sum of each player and the player to reach a total of 15 or more will win the first place and the game stops. The code then checks for the second and third place winners. The code will print out to the user the winners in order. If 2 or all the players hit the same sum, you can consider them all first place winners (for example, if player 1 and 2 hit the same sum that's >= 15 and 3rd player hits a sum less than 15, then you can say 1st and 2nd players win first place and 3rd wins second place). For this question, loop(s) and conditionals should be used otherwise you will lose marks. Don't hardcode the output otherwise marks will be deducted. The output should be as follow (note: no user input is required): Player 1 rolls a 1 and a 1 Player 1 now has 2 Player 1 rolls a 6 and a 1 Player 1 now has 9 Player 2 rolls a 3 and a 21 Player 2 now has 5 Player 3 rolls a 5 and a 1 Player 3 now has 6 Player 1 rolls a 4 and a 3 Player 1 now has 16 Player 2 rolls a 6 and a 1 Player 2 now has 12 Player 3 rolls a 6 and a 5 Player 3 now has 17 Player 3 wins the first place with a total of 17 Player 1 wins the second place with a total of 16 Player 2 wins the third place with a total of 12
Expert Answer:
Answer rating: 100% (QA)
python import random Define the number of players and the winning score numplayers 3 winningscore 15 Initialize player scores and turn counter playerscores 0 numplayers turn 0 Simulate the game until ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
"How might incorporating personalized learning paths for employees impact their skill acquisition and overall performance within an organization's training and development program?"
-
In this project, we will write a program that controls a quiz show, much like the many popular TV shows. The program will read in a group of questions and their multiple choice answers, storing them...
-
In the conversion of a-ketoglutarate to glucose, which of the following compounds are not obligatory intermediates in this pathway? * Oxaloacetate O Fructose 1,6 bisphosphate O Malate O 1,3...
-
Sketch the graph of the inequality. 1. y 5 2. x < - 3 3. y 5 - 2x 4. 3y - x 7 5. (x - 1)2 + (y - 3)2 < 16
-
If there is a significant difference between p 1 and p 2 and between p 2 and p 3 , can you conclude that there is a significant difference between p 1 and p 3 ?
-
Explain how letters of credit protect sellers in overseas sales of goods transactions. Explain how they protect buyers in overseas sales of goods transactions.
-
Kretz Corporation prepares monthly financial statements and therefore adjusts its accounts at the end of every month. The following information is available for March 2010: a. Kretz Corporation takes...
-
12.Indicate, by clicking on the relevant boxes, whether the following statements are true or false?
-
SAE specifications call for the low-side R-134a servicehose to be A) Solid blue with a black stripe B) Solid blue with no stripe C) Solid blue with a yellow stripe D) Solid black with a blue stripe...
-
The weighted average cost of capital for the firm is 20% and the do not have any liabilities on their balance sheet. The stock price is $ 99 per share RIGHT NOW . Also we know their Earnings per...
-
Rene's Used Cars is wholly owned by Rene. Rene has a stock certificate evidencing his ownership in Rene's, marked "Certificate No. 1, 1,000 shares of stock in Rene's Used Cars 4 Sale, Inc." As part...
-
Performance appraisal is not merely for appraisal but it is for the accomplishment and improvement of performance". in the light of statement explain the concept and objectives of performance...
-
Financial ratios can be used to evaluate the shares of Lockheed Martin. According to a significant body of research, they are classified into liquidity, financial leverage, and profitability ratios....
-
A long straight horizontal wire carries a current I = 3.50 A to the left. A positive 1.00 C charge moves to the right at a distance 3.50 m above the wire at constant speed v = 5000 m/s What are the...
-
Determining Retained Earnings and Net Income The following information appears in the records of Becker Corporation at year- end: Accounts Receivable $32,000 Retained Earnings Accounts Payable 12,000...
-
Bernie is aged 45, an Australian citizen and tax resident in Singapore during 2021. She is the finance director of Billion Pte Ltd (BPL) and has been in this position since 2020. BPL is a wholly...
-
What exactly is a prima facie duty? How does an ethic of prima facie duties differ from monistic and absolutist ethical theories?
-
If the value of credits[0].length is not equal to credits[1].length, you know credits is ____________ array. a. A three-dimensional b. A jagged c. A partially populated d. An uninitialized
-
Envisioning program components as objects that are similar to concrete objects in the real world is the hallmark of ____________. a. Command-line operating systems b. Procedural programming c....
-
You created an interactive RentalDemo class that obtains all the data for four rentals from Sammys Seashore Rentals, including details about the contract number, length of the rental, and equipment...
-
Which of these statements regarding the origin of life is false? (a) Life originated on an Earth whose atmosphere contained high levels of oxygen. (b)Miller and Urey obtained amino acids and other...
-
The primary problem with the hypothesis that life on Earth originated on Mars is that (a) Mars has never had water. (b) the proposed Martian fossils are much smaller than the tiniest bacteria on...
-
Which statement about human evolution is true? (a) The earliest fossils of modern humans are almost 200,000 years old. (b)Humans are descended from chimpanzees. (c) Modern humans are the only...
Study smarter with the SolutionInn App