 Let's discuss the kinds of errors that you can get in Python. The first type of error you can get is a parse error, also called a syntax error. This happens when you say something that's grammatically incorrect in Python. For example, if I were to type 3 plus times 5, the shell would tell me that's invalid, and you'll notice that it points out where the error is. Let's open up a program that has an error in it, and you'll notice that there's a gray background on some of these lines. Thani colorizes things, and when you see something in gray, that means that something is incomplete. But let's ignore that for the moment and try running the program and see what happens. And we have a syntax error, a parse error, in line number 3. Well, let's look at line number 3. It looks perfectly good. Parentheses are balanced. The division is proper. Why does it say line 3 when the error is really here on line 2, where we've forgotten the closing parenthesis? And the answer is, it's because of the way Python parses your programs. Have you ever buttoned your shirt and found out when you get to the bottom that you're out of buttons? Now, where did that error start? Did it start at the bottom, or was it somewhere up further on? The answer is usually it was up somewhere near the top, and you forgot a button or a buttonhole, and that's why you're out of buttons when you get to the bottom. Python works in somewhat the same way. It's toodling along here at line number 2. This looks good. Equal sign is cool. Input, I know what that is. Here's my opening parenthesis. Here's a sink double quote. And here's the closing double quote. Oh, there's no closing parenthesis here. Maybe it's on the next line. And so it goes to the next line, finds the word AVG here and says, I can't go any further. Throws up its hands, gives up, and says, that's where the error is. I'm out of buttons. Moral of the story. When you get a syntax error, Python will give you the line number where it gave up, where it could not go any further and make a valid program. That means that your error may be on that line, and it may be somewhere above where the error truly started to happen, just like buttoning the shirt. Those are parse errors. The next kind of error we want to consider is a type error, which happens when you try to do an operation that was not intended for a data type. Let's take a look at this program where we fixed the closing parenthesis so we no longer have a parse error. And let's run it. Our first number will be three, and the second number will be four. And in line three it says, unsupported operand types for division, string and float. The reason this happened is because we got num1 and num2 as input, and remember, input always gives us back a string. The num1 plus num2 worked out okay because by coincidence we can add strings together, but when you have that string, num1 plus num2, and try to divide it by a floating point number 2.0, Python says, time out, you can't do that. You cannot divide strings and floats by one another. A third type of error that you can get when you're programming is called a name error. In this version of the program we fixed the type error by putting in the call to float on lines one and two. But we've introduced a new error on line four by using the word average when in line three the variable name was really AVG. So let's see what happens when we run the program. The first number is three, our second number is four, and the program bombs out in line four because it says the name average is not defined. The fix would be to either change line three to be average or line four to be AVG, and let me take my caps lock off while I do that. And now if I run the program, when I have three and four, the average is 3.5. The fourth type of error that you'll encounter when you program in Python is the value error, and that happens when you give a function input that it wasn't designed to handle. I fixed the name error in this program by converting my inputs to floats in line one and two. But if I give the float function bad input, for example by typing the word three instead of the number three, I'll get a value error that says, no, I can't convert THRE to a valid floating point number. Later on in the course, we're going to learn how to catch these errors and respond to them in a good way. Those are the four main kinds of errors that you'll encounter when programming in Python. The first few times that you get an error, you're sort of going to freak out and you're going to just have no idea what's going on. Don't panic, take a deep breath, look carefully at the error message, read it completely, figure out which kind of error it is, and then look carefully at the line where the error occurred, and again because of our shirt buttoning problem, look a little bit above where the error was pointed out, if it's a syntax error, and after a while you'll get used to seeing some of these errors come up and when you see an error you won't need to freak out. You'll say, oh yeah, I remember that one and I remember how I fixed it and your programming will go ever so much faster.