Before solving this problem, please read over the POTD Guide.
Write a math quiz program that works as follows: it begins by printing an arithmetic problem of your choosing. 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. Open the
P01_quiz1_test.py
in Thonny and click the ‘Run’ button to
run it. For this program, the test file only checks whether your
program’s output includes What is
. In future programs, your
output will be checked much more thoroughly. If your program passes the
test, you should see output that ends with something like the following
after running P01_quiz1_test.py
:
P01_quiz1_test.py . [100%]
============================== 1 passed in 0.05s ===============================
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. If you pass the testing script 100%, you’ll get 100% on the POTD.
When you’re finished, submit your finished POTD file
(P01_quiz1.py
, in this case) to the P01 assignment on
Canvas.