From the course: Introduction to Python: Learn How to Program Today with Python by Pearson

Unlock this course with a free trial

Join today to access over 25,400 courses taught by industry experts.

Debug errors

Debug errors

Okay, so now I want to talk a bit more about errors. First, I've got a problem here, a temperature converter. You're going to take a temperature in Fahrenheit as input and then tell the user what it is in Celsius. So you can go to Problems, Problem 3, Temperature.pi, and you can pause and work on this now. Welcome back. Now, I'm going to work on this. Let's see, we're going to take in a temperature in Fahrenheit, so I'll call it tempF. Do some calculation. I like to just work on stuff a little bit at a time. So for now, I'm not going to do the full calculation. I'm just going to create a tempC variable here, and when we're printing it out, I'll add a plus and tempC to print it out. Running a bit at a time helps you catch bugs faster when they happen, as opposed to writing a whole bunch and then maybe being overwhelmed because you're not sure what's going wrong. So temp F, 32, print out temp in C is 32. So great, no errors, the result is wrong though. So let's fill it in now. And just…

Contents