Dealing With Exceptions

Thomas J. Kennedy

Contents:

1 The Problem

This time… let us be (more than) a little cheeky. Back in high school… I was that kid in AP Computer Science. I spent $70 on Java book and learned how to build GUIs with the Java swing API. I needed something to do during class after finishing an assignment on the first day.

One day… I had finished an assignment and asked a classmate to test it. Instead of entering a number (e.g., 7) he entered the corresponding word (e.g., seven). Of course… my program threw an exception. I told him to try again a minute later… this time instead of an exception… there was a dialog box with a fairly tame insult.

Let us develop a program that handles various exceptions (albeit without the insults). Let us deal with…

These are (most of) the exceptions that I encounter when writing Python code. Having some code snippets prepared for reference… can be quite useful.

1.1 Input

This subsection will describe the input content, format, and overall structure.

1.2 Output

This subsection will describe the output corresponding to the sample input listed in Input.

2 Your Tasks

This section will describe the code that you will

as part of the assignment

3 Mechanics

You can run the main program with…

python3.11 exception_snippets.py

The test code can be run with…

python3.11 -m pytest -v tests

4 Files

There are two (2) files in this assignment:

You will be working in shapes.py. Do not modify the other files.

You can access the starting files on GitHub. You may either clone the starting repository (through Git) or download a zip file.

5 Grading

This section will summarize the grading criteria for the assignment, with a particular emphasis on the correspondence to any PyTest or unittest code that was provided as part of starting code base.

6 Submitting

You will submit your completed copy of exception_snippets.py as a file upload through Canvas.

Do not alter any of the other source code files, nor change the module interface.