Write a program which randomly rolls a die 100 times (results in one of the six sides). Use the radint (a, b) function from the random module which returns a value from the interval [a, b]. Write the result of each die roll (one, two, three, four, five, or six) to a file named "dieroll.dat" and at the end provide overall statistics (how many times which side of the die was rolled) which should also be written to the file. Opening the file might fail because of multiple reasons. In the case of an exception occurring, print a corresponding message on the screen and stop the executing of the program by calling sys.exit () from the sys module.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
Python
Write a program which randomly rolls a die 100 times (results in one of the six sides). Use the
radint (a, b) function from the random module which returns a value from the interval [a, b].
Write the result of each die roll (one, two, three, four, five, or six) to a file named "dieroll.dat"
and at the end provide overall statistics (how many times which side of the die was rolled) which
should also be written to the file.
Opening the file might fail because of multiple reasons. In the case of an exception occurring,
print a corresponding message on the screen and stop the executing of the program by calling
sys.exit () from the sys module.
Transcribed Image Text:Write a program which randomly rolls a die 100 times (results in one of the six sides). Use the radint (a, b) function from the random module which returns a value from the interval [a, b]. Write the result of each die roll (one, two, three, four, five, or six) to a file named "dieroll.dat" and at the end provide overall statistics (how many times which side of the die was rolled) which should also be written to the file. Opening the file might fail because of multiple reasons. In the case of an exception occurring, print a corresponding message on the screen and stop the executing of the program by calling sys.exit () from the sys module.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
InputStream
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning