Saravji's Hut

Logo

The place where change happens.

Project on GitHub Saravji/saravjis_hut

Saravji's Hut YouTube channel

Saravji on Twitter

Foundations of Programming (Python)

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.

One 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 Modules Materials Lists