From the course: Programming Foundations: Real-World Examples
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Validate external input - Python Tutorial
From the course: Programming Foundations: Real-World Examples
Validate external input
- Time to finish cleaning up the house. I like to put on a little music when I clean. And Olivia, there's a few more dishes in the dishwasher. Do you mind starting that? - Sure. - Thanks. I'll just stay in here and vacuum at the living-room. Looks like we ran into another error. Unfortunately, I have no idea what caused this or why this problem occurred. Just knowing that something's wrong doesn't help me to figure out what I need to do to fix it. When an error occurs the source of that error should raise an exception and pass along information about the problem so the program can do something to handle the error. - Apparently, this was the dishwasher. I think we tripped the curcuit. - Ah, thanks. Now that you know an error has occurred and the reason for the problem you can do something to handle it. To demonstrate this scenario, I've created a class to simulate a circuit breaker in this script called start_11_02_circuit_breaker. The circuit breaker class has two properties:…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.