Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python (.py file) Note: Please comment the steps and post a screenshot of your output, source code, and trials. As well as including spaces and

Python (.py file)

Note: Please comment the steps and post a screenshot of your output, source code, and trials. As well as including spaces and new lines. Thank you.

image text in transcribedimage text in transcribed

Part 1: Roll the Dice In games with two dice (such as Monopoly), rolling two 6-sided dice and getting the same side or number on both dice is called "doubles" (i.e. the first die rolls a 5 and the second die rolls a 5 at the same time). One special type of "doubles" roll is called "snake eyes," which is rolling two 1's at the same time. There are many kinds of dice! For this assignment you will be writing a program which first prompts the user for the number of sides to the pair of dice they will be rolling. Your user should be able to select from among 4-, 6-,7-, 8-,10-, 12-, 16-or 20-sided dice (ie. the user is selecting the number of the sides on each die). You can assume that they will enter integers (not floats or strings). You will need to validate their input before you continue (i.e. entering 13 should cause your program to tell the user that their input is invalid). You should re-prompt the user to enter a value if they supply bad data. Hint: use a "while" loop to keep the user 'trapped" until they supply you with "good" data for the number of sides. 8 O- Some multi-sided dice Next, your program should keep 'rolling the dice" until it gets snake eyes. This means that you will roll two virtual dice of the same specified size at a time. The program should "announce" every pair rolled and then tell the user how many "rolls" were required to get a pair of ones. You should also keep track of how many times your roll came up with "doubles" along the way (but you shouldn't end the program until you roll "snake eyes") In addition, you will want to calculate the average roll for each die and present this information to the user. See the sample program below to see what this should look like. You should format this number to two decimal places. In addition, you will want to calculate the average roll for each die and present this information to the user. See the sample program below to see what this should look like. You should format this number to two decimal places. # Sample input: How many sides on your dice? -6 Sorry, that's not a valid size value. Please choose a positive number How many sides on your dice?6 Thanks! Here we go.. # Sample output : 1. die number 1 is 5 and die number 2 is 3. 2. die number 1 is 2 and die number 2 is 2. 3. die number 1 is 1 and die number 2 is 5 4. die number 1 is 5 and die number 2 is 1. .continue 16. die number 1 is 1 and die number 2 is 1. You got snake eyes! Finally! On try number 16! Along the way you rolled doubles 5 times The average roll for die #1 was 2.95 The average roll for die #2 was 3.20 Note that the 'snake eyes" roll that causes your loop to end should count as a 'doubles" 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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

Identify conflict triggers in yourself and others

Answered: 1 week ago