Question
*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.)
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
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