Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*IN Python language * write a program that simulates the rolling of a single fair dice an arbitrary number of times. The program should: 1.

*IN Python language*

write a program that simulates the rolling of a single fair dice an arbitrary number of times. The program should:

1. Ask the interactive user how many times the dice should be rolled. Any number from 1 to 100000 is a legal entry.

the program should print an error message to the screen and prompt again if the user gives inappropriate input.

2. Roll the simulated dice the number of times requested, printing the number on its own line each time, with leading spaces that put the 1 in the first column, 2 in the second column, ..., and 6 in the sixth column.

3. After the last dice is displayed, the program should print out 6 more lines that tell how many 1s were rolled, how many 2s, .., how many 6s.

The printing described above goes to two places: to the screen visible to the interactive user, and to a textfile text.txt.

__

Here is an example of the output file that could result in after the interactive user asks for 22 rolls of the dice. (Since

these throws are simulated random, I cant tell you exactly what would happen for a given execution of the program.)

image text in transcribed

1 4 1 4 6 6 4 6 1 1 6 Number of times we got 1:4 Number of times we got 2:2 Number of times we got 3:3 Number of times we got 4:4 Number of times we got 5:4 Number of times we got 6:5

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

=+employee to take on the international assignment?

Answered: 1 week ago

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago