Section 3.1 Introduction to Debugging
“The art of debugging is figuring out what you really told your program to do rather than what you thought you told it to do.” — Andrew Singer
This chapter will spend some time talking about what happens when errors occur as well as how to fix the errors that you will inevitably come across.
Before computers became digital, debugging could mean looking for insects impeding the functioning of physical relays as in this somewhat apocryphal tale about Admiral Grace Hopper, a pioneer of computer programming.
1
https://www.computerworld.com/article/2515435/app-development/moth-in-the-machine--debugging-the-origins-of--bug-.html
2
https://en.wikipedia.org/wiki/Admiral_Grace_Hopper
Nowadays, debugging doesn’t involve bug guts all over your computer but it can still be just as frustrating. To cope with this frustration, this chapter will present some strategies to help you understand why the program you wrote does not behave as intended.
Many people think debugging is some kind of punishment for not being smart enough to write code correctly the first time. But nobody does that, failure in programming is part of the deal. Here’s a fun video to keep in mind as you learn to program.
Simone Giertz - Why you should make useless things BY–NC–ND 4.0 International Ted.com
3
www.youtube.com/watch?v=c0bsKc4tiuYCC
4
ted.com
Subsection 3.1.1 Learning Goals
- To understand common kinds of exceptions and their likely causes
- To practice finding and fixing errors
Subsection 3.1.2 Objectives
- Identify errors based on error messages
- Understand various kinds of errors: ValueError, TypeError, SyntaxError, NameError
You have attempted of activities on this page.