Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started