CSC148H5 Lecture Notes - Lecture 3: Wisdom Tooth, Gnu Readline, Pogrom

36 views5 pages
24 Jan 2017
School
Course

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents