Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Python 3.6 Create a function n_sided_dice_roll to simulate the rolling of an n-sided dice. This function will utilize the built-in random.randint function to generate
Use Python 3.6
Create a function n_sided_dice_roll to simulate the rolling of an n-sided dice. This function will utilize the built-in random.randint function to generate a random number in the range 1 to n (including both end points) and return the generated random number. User will provide the value for n. To demonstrate, youll call the n_sided_dice_roll function 5 times and output the number you got every time.
Below are some helpful pointers.
import random # https://docs.python.org/2/library/random.html (Links to an external site.)Links to an external site. has more information
>>> help(random.randint)
Help on method randint in module random:
randint(a, b) method of random.Random instance
Return random integer in range [a, b], including both end points.
Example of expected output is:
Enter the number of sides of the dice: 10
Following numbers are generated when rolling a 10-sided dice.
For roll 1, you got: 10
For roll 2, you got: 5
For roll 3, you got: 8
For roll 4, you got: 2
For roll 5, you got: 6
Bonus (optional):
Create two n-sided dices and output the numbers you get. Example output is:
Enter the number of sides of the dice: 10
Following numbers are generated when rolling two 10-sided dices.
For roll 1 you got: 8, 6
For roll 2 you got: 5, 7
For roll 3 you got: 7, 1
For roll 4 you got: 2, 4
For roll 5 you got: 6, 10
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