Homework 9
CS1210 Computer Science 1 - Fall 2021
Due Monday, Nov. 29, by 8:00pm
6 points
1. Implement a tkinter-based GUI program for a simple math game.
Your program should present randomly generated
simple math problems involving addition, subtraction, multiplication,
and division of whole numbers.
For addition, subtraction, division, both operands should be non-negative integers should be less than 1000.
For multiplication, both should be less than 100. All
problems should have positive integer answers. Do not generate
problems having negative, floating point, or undefined results. Thus,
for example, 4 - 6, 23 / 2, and 1 / 0 are all disallowed.
You may design your user-interface however you'd like but it must:
- provide a way to display the current problem (this could be a Label widget, for example)
- provide a place for the player/user to enter their answer (this could be an Entry widget)
- provide a way for the user to indicate that their answer should be checked for correctness (this could be a Button widget)
- provide feedback on whether or not the player's answer is correct
- allow the player to enter and test a new proposed answer if the current answer is wrong.
- disallow entry of new answers for the current problem once a correct answer has been entered.
- keep track of the number of incorrect answers for the current problem, and display that number (with text that makes it clear what it is) in the GUI.
- provide be a way (e.g. via radio buttons) to set the "current problem type" as one of: +, -, *, /, or anything. The default should be "anything." Whenever problems are generated, the current problem type should be used to determine the kind of problem. E.g. if the current problem type is '+' only addition problems should be generated until the current problem type is changed. When the current problem type is "anything", +, -, /, and * problems should be generated with equal likelihood.
- provide a way for the player to request a new problem.
- ensure that the same problem is never presented more than once in the same game.
- provide a way to quit the game
- save information on: the number of problems attempted, the number solved, and the average number of total guesses (correct and incorrect) per solved problem (i.e. ignoring unsolved problems), and then print text with this information in the Python shell when the player quits the game.
Submit to ICON exactly one Python file.