Exceptions and Assertions
At a glance
- Price Free to watch, no sign-up
- Runtime 43 min
- Topics Computer Science
- Source MIT, Introduction to CS and Programming using Python
- Lecture Lecture 13 of 25
- Language English
MIT lecturer Ana Bell covers exception handling and assertions in Python as part of 6.100L, Introduction to CS and Programming using Python. The lecture walks through how exceptions arise during program execution, how to catch and handle them with try and except blocks, and how to distinguish exceptions a programmer anticipates from bugs that should stop execution. Bell demonstrates raising assertion errors to enforce assumptions about program state, such as checking function arguments before they cause downstream failures, and discusses when to use exceptions versus assertions in program design. Code examples run through common error types and show how unhandled exceptions crash a program versus how handled ones let execution continue gracefully. Aimed at students partway through an introductory programming sequence, the lecture builds directly on earlier material about functions and control flow.