Write the function below per the docstring. f rollUntil3ConsPrimes (): ***Use the random module to roll a fair dice til there have been 3 consecutive prime numbers rolled. e starting score is 100. The final score is the arting score decreased by 5 for every non prime roll made. turns the list of dice rolls made and the final score as a tuple. e a while loop and a list accumulator. Use appropriate 1per functions - you MUST use at least one helper function. nt: in the while loop, ue a counter to count the number of consecutive imes rolled by using a counter that increases its count if a prime is 1led, but if a prime is not rolled the counter is set back to ro.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
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
Transcribed Image 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
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY