Question: [Python]Develop a GUI that can be used to teach elementary school children addition and subtraction. The GUI contains two Entry widgets and a Button widget.
[Python]Develop a GUI that can be used to teach elementary school children addition and subtraction. The GUI contains two Entry widgets and a Button widget. At start up, the program will generate two single-digit pseudorandom numbers a and b and an operation op, which should be either addition or subtraction. Addition and subtraction should be equally likely to be chosen by your GUI, and the choice of the numbers should be independent of the choice of the operation. Do not in any way link the choice of the numbers and the operation. The functions found in the random module are helpful here. The expression a op b will be displayed in the first Entry widget, unless a is less than b and the operation is subtraction in which case b op a will be displayed. (We don't want the children to be confused by negative answers). Examples of expressions displayed could be 3 + 2 =, 4 + 7 =, 5 - 2 =, 3 - 3 =, etc. An expression like 2 - 6 = would not be displayed. The child will enter, in the second Entry widget, the result of evaluating the expression shown in the first Entry widget and click the Enter button. If the correct result is entered, a window should pop up indicating that the child got the answer correct. The following shows a sample entry when you write Ed().mainloop() in the IDLE window: Suppose the child types an incorrect answer into the rightmost Entry box: When the child clicks the Enter button a message will pop up: After that message box is dismissed the incorrect answer is cleared: Once the child types the correct answer into the Entry: and clicks Enter, then the pop up window with a positive message is displayed: When this happens, the GUI should generate a new problem and display it for the child so that he/she can continue. This should continue indefinitely. An example is shown below: Your GUI should recover from non-numeric entries. When the child types something that cannot be evaluated to a number, such as the following: then the following pop-up window should display: After this box is dismissed the invalid value should be cleared so that the child can try again. The problem should not be changed until the child has gotten the answer correct. The constructor and make_widgets() method have been written for you and can be found in the template file uploaded to D2L. Do not change these methods. Instead you must write the new_problem() and evaluate() methods. The new_problem method generates a new arithmetic problem according to the rules described above and places the problem into the relevant entry. The evaluate() method is the handler for the button. It evaluates the child's answer entered into the second entry against the answer for the problem found in the first entry and takes the appropriate action based on the situation. Use this template. Pics below.
class Ed(Frame): 'Simple arithmetic education app'
# You can change the geometry manager to grid if you like, but # otherwise don't change this method def __init__(self,parent=None): 'constructor' Frame.__init__(self, parent) self.pack() Ed.make_widgets(self) Ed.new_problem(self)
# You can change the geometry manager to grid if you like, but # otherwise don't change this method def make_widgets(self): 'defines the Ed widgets without the numerical values' self.ent1 = Entry(self) self.ent1.pack(side=LEFT) self.ent2 = Entry(self) self.ent2.pack(side=LEFT) Button(self, text="Enter", command=self.cmd).pack(side=RIGHT) # Write this method def new_problem(self): 'creates new arithmetic problem and places it into the widgets'
def cmd(self): self.eva(self.ent2.get()) # Write this method def eva(self,x): 'handles button "Enter" clicks by comparing answer in entry to correct result'![[Python]Develop a GUI that can be used to teach elementary school children](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2f2a5c0c3f_86166f2f2a52e9a5.jpg)
2.2 Not Thatwas incomect. Try again. 2-2 nin Enter 2.2 Enter Enter Enter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
