Question: Write a python program for a two-player rolling dice game (namely, P1 and P2). Each player has a counter to record their scores (initially 0).

Write a python program for a two-player rolling dice game (namely, P1 and P2).

Each player has a counter to record their scores (initially 0). Each time, a player would roll two dice. The sum of the two dice would be added to the corresponding players counter. If the player rolls doubles (i.e. the two dice have the same number), then the player can continue to roll the dice. Otherwise, it would be the other players turn. When the input is 0, print the players scores. Sample Test case 1: Input 12 31 23 0

Expected output P1:8 P2:4 Detailed explanation: Player 1 rolls the dice 1 and 2. The counter of Player 1 becomes 3. Player 2s turn. Player 2 rolls the dice 3 and 1. The counter of Player 2 becomes 4. Player 1s turn. Player 1 rolls the dice 2 and 3. The counter of Player 1 becomes 8. Input 0 means the end of the input and print the values of the counters. Sample Test case 2: Input 11 34 25 61 34 0

Expected output P1:16 P2:14 Detailed explanation: Player 1 rolls the dice 1 and 1. The counter of Player 1 becomes 2. As it is a double, still Player 1s turn. Player 1 rolls the dice 3 and 4. The counter of Player 1 becomes 9. Player 2s turn. Player 2 rolls the dice 2 and 5. The counter of Player 2 becomes 7. Player 1s turn. Player 1 rolls the dice 6 and 1, The counter of Player 1 becomes 16. Player 2s turn. Player 2 rolls the dice 3 and 4. The counter of Player 2 becomes 14. Input 0 means the end of the input and print the values of the counters.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!