0% found this document useful (0 votes)
3 views1 page

Python Code Debugging Guide

The document provides an example of Python code that contains three syntax errors and presents the corrected version. Key corrections include adding missing colons and fixing variable names. The debugged code demonstrates proper use of if-else statements and prints relevant messages based on conditions.

Uploaded by

knightking102003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Code Debugging Guide

The document provides an example of Python code that contains three syntax errors and presents the corrected version. Key corrections include adding missing colons and fixing variable names. The debugged code demonstrates proper use of if-else statements and prints relevant messages based on conditions.

Uploaded by

knightking102003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Code Debugging: Example Code in Python

Python code with 3 syntax errors: Debugged code:


print("This line of code is before both IF-ELSE functions")

countervariable = 125 # Correct variable name


if (countervariable < 100): # Added missing colon
print("Counter is smaller than 100")
print("This line is in the first if section")
This line of code is before both IF-ELSE functions else: # Added missing colon
Counter is greater than 100 print("Counter is greater than 100")
This line is in the first else section print("This line is in the first else section")
Number is a positive number
This line is in the second if section number = 3
This line of code is after both of the IF-ELSE functions if (number > 0): # Added missing colon
print("Number is a positive number")
print("This line is in the second if section")
else: # Added missing colon
print("Number is a negative number")
print("This line is in the second else section")

print("This line of code is after both of the IF-ELSE

You might also like