Let’s start a brand new module in the SoloLearn Introduction to Python course. We are in module two. Module two is about working with data.
This module is full of different concepts. The topics featured in this module are:
- Debugging
- Best practices and standards
- Inputs and outputs
- Data types
- Data conversions
- Fixing data types
- Comparison operators
- Logical operators
- Combining comparison operators and logical operators
Looks like a lot of information, right? I am breaking this module into multiple posts that will cover each of these topics. This way, it will be easier for you to read and process everything in small chunks.
This week is the first post in this module and will be about debugging. Debugging is a crucial skill in any programming language, making it essential for every developer to possess. SoloLearn shares tips for debugging in Python, but you can use these tips in any programming language since debugging is universal everywhere in programming.
Next week, I will continue to progress through module two with the next topic. Part two of this module will examine some of the best practices and standards for Python.
What is debugging?
Debugging is what developers say when they are fixing code. Developers go through their code looking for errors or “bugs” as developers refer to them. Web development has the following three elements, regardless of what language you use:
- writing code
- testing code (developers can call this executing code)
- debugging
Every developer debugs code because bugs occur frequently in code no matter what language is being used. Think of it just like proofreading for coding. This makes developers kind of a digital mechanic trying to figure out what is wrong so they can fix it and get it up and running again.
The thing about bugs is that they could be a large amount of code that isn’t working or the tiniest error. That means typos and misplaced tags can cause problems in your code. When you are working in a case-sensitive language like Python, capitalizing the wrong letter could result in your entire program not working correctly.
It is similar to how Christmas lights work around the holidays. Often time when one light goes out, the entire strand of lights won't work. Luckily, programming languages like Python are there to help developers find errors in their code.
Enter the error message.
An error message is the message the computer tells the developer so they know that there is an error in the code. Error messages will look different depending on what type of console you are using. However, they work the same way.
When the computer encounters a bug, the code will stop running, and an error message will pop up. Multiple errors will stop running on the first bug it finds until it is fixed. Then it will look for the next error in the code.
When you get an error message, SoloLearn tells students to stay cool. Next, read the error message. The error message will tell you what kind of error it is and where it is in your code.
Once you read the message, go to the spot in your code and read the line the error message specified, and fix the error. Some errors might not be in that specific line, so always read 1-2 lines before the specified line and 1-2 lines after it. The secret to debugging is working in small chunks.
That means writing code in small chunks, testing it, and then debugging. It is much easier to code this way versus writing all the code and then debugging it afterward. You'll learn more about functions in a later module, but functions are a developer's best friend when debugging code.
The best way to avoid having many errors is by spotting them early, and coding in small chunks helps cut down the errors.
This means a lot of double-checking, but that’s a lot of what coding is about. There are lots of errors you’ll encounter in your code. When I’ve taught my Level M classes, a common bug students often encountered was calling variable names that weren’t defined yet.
They were using two different variable names, confusing the computer. They learned to double-check the variable names they were using in their code when they got error messages.
Top comments (0)