Make sure your code runs and is doing calculations correctly. Write code in the editor and do not include prompts in the editor file. This will use the random module, specifically, the randint function from the random module. If we wanted to roll the dice 5 times, we could do this as follows:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help with these practice quation using python programming 

Review Work
Make sure your code runs and is doing calculations correctly. Write code in the editor and do not include
prompts in the editor file.
This will use the random module, specifically, the randint function from the random module.
If we wanted to roll the dice 5 times, we could do this as follows:
from random import randint
for i in range (5):
print (randint (1,6))
5
File Preview
3
5
6
5
Kemember how while works – look at the lecture notes and worksheets.
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.
Transcribed Image Text:Review Work Make sure your code runs and is doing calculations correctly. Write code in the editor and do not include prompts in the editor file. This will use the random module, specifically, the randint function from the random module. If we wanted to roll the dice 5 times, we could do this as follows: from random import randint for i in range (5): print (randint (1,6)) 5 File Preview 3 5 6 5 Kemember how while works – look at the lecture notes and worksheets. 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.
>>>
Kemember how while works – look at the lecture notes and worksheets.
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:>>> Kemember how while works – look at the lecture notes and worksheets. 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 2 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education