Lines 30-41

The main driver of the application is main(), called from the top-level if the script is invoked directly. If imported, the importing function either manages the execution by calling doprob(), or calls main() for program control. main() simply calls doprob() to engage the user in the main functionality of the script and prompts the user to quit or to try another problem.

Since the values and operators are chosen randomly, each execution of matheasy.py should be different. Here is what we got today (oh, and your answers may vary as well!):

 % matheasy.py 7 - 2 = 5 correct Try another? ([y]/n) 7 * 6 = 42 correct Try another? ([y]/n) 7 * 3 = 20 incorrect… try again 7 * 3 = 22 incorrect… try again 7 * 3 = 23 sorry… the answer is 7 * ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.