Presentation is loading. Please wait.

Presentation is loading. Please wait.

Debugging 101 Exterminating Vermin.

Similar presentations


Presentation on theme: "Debugging 101 Exterminating Vermin."— Presentation transcript:

1 Debugging 101 Exterminating Vermin

2 Types of Errors Syntax Errors Runtime Errors Logic Errors

3 Syntax Error A "grammatical" error in the program
Results in a ParseError message Examples: Missing punctuation Malformed expressions At runtime, interpreter scans entire program and discovers these before executing any of the program

4 Runtime Error An error that occurs when the interpreter executes a statement Examples: NameError Misspelled variable or function name Use of variable in expression before it is assigned an initial value TypeError Operand of incorrect type for operator ValueError Passing wrong type of data to function

5 Logic Error The program appears to work without error
However, the output is not correct Detect these using test cases

6 Using print() to Debug During development, add print() statements at strategic places in the program to help you understand how the program is working see the values of variables Comment out or remove the debugging print() statements before submitting

7 Debugging with print()
# A buggy version of chickenfeed with extra debugging print() statements temperature = int(input('Enter the temperature in degrees fahrenheit: ')) totalWeight = int(input('Enter total chicken weight in pounds')) if temperature <= 60: print(‘It’s cold! temperature =‘, temperature) # for debugging feedAmt = totalWeight * .12 elif temperature >= 90: print(‘It’s hot! temperature =‘, temperature) # for debugging feedAmt = totalWeight * .08 else: print(‘It’s comfortable! temperature =‘, temperature) # for debugging feedAmt = totalWeight * .1 print('Feed them ', feedAmt, " pounds of Robert's Best")


Download ppt "Debugging 101 Exterminating Vermin."

Similar presentations


Ads by Google