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.
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.
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
Related questions
Question
Python
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images
Knowledge Booster
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.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning