Skip Navigation or Skip to Content

Foundations of Programming (Python) Labs

LAB 07-C: Structured Error Handling:

In this Lab, we’ll continue with our code from Lab 07-B.
You’ll add error handling whenever there is an IO interaction.
You do not need to create your own classes.

  1. Make a copy of the script from LAB 07-B and save it as Lab07_C.
  2. Add code to catch errors around file operations (2 areas)
  3. Add code to catch errors around the user input operations. Handle non-numeric inputs and value zero input for the number used as denominator seprataly.
  4. Test the script and write down how the code works.

Note about testing: Make sure to test that the script works as expected (with ‘good’ values).
But also think about what values to use to test that you can’t break your script.
These tests typically are more efficient.

Back to self guided, Video only Materials

Back to self guided, Video plus Written Materials

Back to guided, Video plus Written Materials plus Personal Guidance, Feedback, and Support (class setting)