sing python program

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

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.
2. Write the function below per the docstring.
def rpt_rollUntil3ConsPrimes(n):
''Roll a dice until 3 consecutive primes are obtained. Repeat this n times.
Uses function from Q1 as a helper function. Returns the maximum score,
the minimum score and the average score as a tuple. Hints: If L is a list of
numbers, max(L) returns the maximum number and min(L) returns
the minimum number.'''
print('Sample run:')
print(' rpt_rollUntil3ConsPrimes(30):')
Mx, Mn, Avg = rpt_rollUntil3ConsPrimes(30)
print('The max score is', Mx)
print('The min score is',Mn)
print('The avg score is',Avg)
File Preview
Q2
Sample run:
rpt_rollUntil3ConsPrimes (30):
The max score is 100
The min score is -25
The avg score is 65.33333333333333
Transcribed Image Text:2. Write the function below per the docstring. def rpt_rollUntil3ConsPrimes(n): ''Roll a dice until 3 consecutive primes are obtained. Repeat this n times. Uses function from Q1 as a helper function. Returns the maximum score, the minimum score and the average score as a tuple. Hints: If L is a list of numbers, max(L) returns the maximum number and min(L) returns the minimum number.''' print('Sample run:') print(' rpt_rollUntil3ConsPrimes(30):') Mx, Mn, Avg = rpt_rollUntil3ConsPrimes(30) print('The max score is', Mx) print('The min score is',Mn) print('The avg score is',Avg) File Preview Q2 Sample run: rpt_rollUntil3ConsPrimes (30): The max score is 100 The min score is -25 The avg score is 65.33333333333333
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Introduction to computer system
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