Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 Create a new script, and add the following at the top of the file; import random. Create a function named roll die that

image text in transcribed

Part 1 Create a new script, and add the following at the top of the file; import random. Create a function named roll die that returns a random integer between 1 and 6, emulating a six-sided die (you will need to make use of the random.randint(function), Design and implement a program that allows the user to roll a die as many times as they wish, outputting the result of the roll each time. Stop the program after the user does not wish to roll any more dice. Add comments to the top of the script specifying the author, the course title the date, and the purpose of the program. Part 2 Modify the roll dhe function by adding a parameter which will allow it to emulate a die with any number of sides. Ask the user how many sides the dice should have each time they want to roll again Part 3 Create a new function named roll dice that takes two parameters: the number of dice to roll, and the number of sides the dice should have. The function should return a list containing the results of each dice roll Modify the program so that the user can now specify how many times to roll the dice after which they can choose to roll another set of dice. Output the result of each roll

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

L = { 0 ^ n 1 ^ n | n > 0 } is a regular language

Answered: 1 week ago