Program of the Day #1

Before solving this problem, please read over the POTD Guide.

Write a math quiz program that works as follows: it begins by printing the arithmetic problem shown below (“What is 4 * 6?”). Then, it prompts the user to enter an answer. Finally, once they have pressed enter, the program prints a message showing the correct answer. Note: we don’t yet know how to check if the user’s answer was correct, but we’ll get there soon! A couple sample runs of such a program are shown below; note that the number on the middle line is what’s typed by the user before they press enter, while the first and third lines are printed by the program.

>>> %Run P01_quiz1.py
What is 4 * 6 ?
24
4 * 6 is 24
>>> %Run P01_quiz1.py
What is 4 * 6 ?
22
4 * 6 is 24

To test your program, first make sure you have pytest installed in Thonny. In Thonny, go to ‘Tools’ on the top menu, then ‘Install Packages’. Type ‘pytest’ in the search bar at the top and click ‘Search on PyPi’. Pytest should come up in the results - click on it and then on the ‘install’ button. Now you have Pytest!

Now make sure your file is named P01_quiz1.py (with the exact capitalization) and the P01_quiz1_test.py file saved to the same folder on your computer. Make sure you have iotest.py saved in that same location as well. Open the P01_quiz1_test.py in Thonny and click the ‘Run’ button to run it. To pass the tests, you’ll need to produce the exact same output as in the example above. In the next POTD, we’ll make it more flexible and able to print different numbers. If your program passes the test, you should see output that ends with something like the following after running P01_quiz1_test.py:

--- Starting Test Runner ---
[PASS] ✅ Arguments:  (with stdin: [''])

----------------------------
Total: 1 / 1 Tests Passed
----------------------------
All tests passed - nice work! 🎉

For each of the POTDs we’ll provide one of these test files - which will be used in grading your POTDs. You don’t need to make any modifications to the test file, nor should you submit the test file to Canvas. Your score on each POTD is simply the proportion of test cases you’ve passed; if you pass all the tests, you will get 100%.

When you’re finished, submit your finished POTD file (P01_quiz1.py, in this case) to the P01 assignment on Canvas.