1. Write the function below per the docstring. def rollUntil3ConsPrimes (): **'Use the random module to roll a fair dice until there have been 3 consecutive prime numbers rolled. The starting score is...


1. Write the function below per the docstring.<br>def rollUntil3ConsPrimes ():<br>**'Use the random module to roll a fair dice<br>until there have been 3 consecutive prime numbers rolled.<br>The starting score is 100. The final score is the<br>starting score decreased by 5 for every non prime roll made.<br>Returns the list of dice rolls made and the final score as a tuple.<br>Use a while loop and a list accumulator. Use appropriate<br>helper functions - you MUST use at least one helper function.<br>Hint: in the while loop, ue a counter to count the number of consecutive<br>primes rolled by using a counter that increases its count if a prime is<br>rolled, but if a prime is not rolled the counter is set back to<br>zero.<br>..<br>print('Q1')<br>print('Sample runs:')<br>for i in range(5):<br>Rolls,Score = rolluntil3ConsPrimes () # note how return is received from<br># a function that returns a tuple<br>print('Rolls made:', Rolls)<br>print('Ending score is:',Score)<br>print()<br>Q1<br>Sample runs:<br>Rolls made: [5, 2, 2]<br>Ending score is: 100<br>Rolls made: [4, 3, 6, 5, 2, 4, 3, 6, 4, 2, 6, 5, 3, 6, 2, 5, 2]<br>Ending score is: 65<br>Rolls made: [2, 5, 1, 4, 3, 6, 6, 5, 3, 2]<br>Ending score is: 80<br>Rolls made: [6, 5, 6, 6, 3, 6, 1, 4, 5, 1, 3, 5, 4, 3, 4, 1, 1, 3, 1, 1, 3, 6, 1, 1, 1, 3,<br>4, 6, 2, 5, 1, 6, 6, 4, 2, 3, 1, 2, 2, 2]<br>Ending score is: -20<br>Rolls made: [2, 2, 6, 1, 3, 4, 2, 5, 5]<br>Ending score is: 85<br>

Extracted text: 1. Write the function below per the docstring. def rollUntil3ConsPrimes (): **'Use the random module to roll a fair dice until there have been 3 consecutive prime numbers rolled. The starting score is 100. The final score is the starting score decreased by 5 for every non prime roll made. Returns the list of dice rolls made and the final score as a tuple. Use a while loop and a list accumulator. Use appropriate helper functions - you MUST use at least one helper function. Hint: in the while loop, ue a counter to count the number of consecutive primes rolled by using a counter that increases its count if a prime is rolled, but if a prime is not rolled the counter is set back to zero. .. print('Q1') print('Sample runs:') for i in range(5): Rolls,Score = rolluntil3ConsPrimes () # note how return is received from # a function that returns a tuple print('Rolls made:', Rolls) print('Ending score is:',Score) print() Q1 Sample runs: Rolls made: [5, 2, 2] Ending score is: 100 Rolls made: [4, 3, 6, 5, 2, 4, 3, 6, 4, 2, 6, 5, 3, 6, 2, 5, 2] Ending score is: 65 Rolls made: [2, 5, 1, 4, 3, 6, 6, 5, 3, 2] Ending score is: 80 Rolls made: [6, 5, 6, 6, 3, 6, 1, 4, 5, 1, 3, 5, 4, 3, 4, 1, 1, 3, 1, 1, 3, 6, 1, 1, 1, 3, 4, 6, 2, 5, 1, 6, 6, 4, 2, 3, 1, 2, 2, 2] Ending score is: -20 Rolls made: [2, 2, 6, 1, 3, 4, 2, 5, 5] Ending score is: 85

Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here