CSC148H5 Lecture Notes - Lecture 3: Wisdom Tooth, Gnu Readline, Pogrom
Document Summary
Plans for this week: exceptions, oo, functional programming tools. So far python function have returned values or modi ed objects. Sometimes however, our function cannot complete successfully, then what should happen e. g calling pop on an empty stack e. g trying to create a faction with 0 denominator. They have to check for error if the function is called. Each call of the function requires a check. Results in more error checking code then actual code. Is assuming that you can nd a value to return that always means error. Ex. def student_gpa(marks): error return could be -1 99. There is no obvious return value cause a person could have negative and p ositive net worth. While a string is possible it is a bad idea. In order to overcome this problem we use exceptions. Exceptions allows you to structure code in natural way so that error handling and recovery isolated from the regular ow of your pogram.