Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a program that uses a function to simulate the roll of a die. Whenever it s helpful, use functions to split your code into
Create a program that uses a function to simulate the roll of a die. Whenever its helpful, use functions to split your code into other functions.
The program should roll two sixsided dice, add the total of the two
Display the results of the dice values
Also, display a special additional message for rolling certain combinations. Two ones Snake eyes! Two sixes Boxcars Two s Ballerina Two s Square Pair You can find websites with these "colorful dice combinations" so feel free to add as many additional named combinations as you would like to
Write the code to display the title in it's own function
Write the code that generates a value for a single die roll in a function named "roll HINT: you'll use the "randint function that's part of the "random module" in this function in order to get a random result between and to return.
Write the code to obtain a value for two dice rolls, add them together, and print the results in a function named "rolldice This will be a void function that doesn't return a value.
Lastly, in a main function, write the code that
Calls the functions to display the title
Ask the user if they want to roll the dice the first time
Loops until the user is ready to call it quits for the night.
Calls the rolldice function
Ask the user if they want to roll again
Hint: Near the bottom of the loop you should use the same variable to save the user choice for continuing or not that you initialize prior to a While loop. Doing so will allow you to check a single variable in your While loop statement rather than something more complex.
Using the sample output below be sure to generate spacing between each roll.
Sample inputoutput:
Dice Roller
Roll the dice? yn: y
Die :
Die :
Total:
Roll again? yn: y
Die :
Die :
Total:
Snake eyes!
Roll again? yn: y
Die :
Die :
Total:
Boxcars!
Roll again? yn: n
Bye!
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