CIS 122 LECTURE Debugging

5 printtaxable income taxableincome didnt define age

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #No longer a trivial issue taxableIncome = income if age < 21: taxableINcome *= 0.5 print(“Taxable income”, taxableIncome) #didn’t define age Watch for unindented : indented statements Watch for unindented early end to a block of statements • Motto: Debugging—the art of finding out what a computer will actually do when it runs your program  ­Its not the art of finding out what you want the computer to do • Basic debugging strategy on “if” and “elif” is inserting print statements to give evidence of what the behavior of the program is Are variables computed correctly? Example code: product = 0 msg = "Type a positive number, or zero to quit " number = float(input(msg)) while number > 0: product = product * number print("Product", product, "Number", number) number = f...
View Full Document

Ask a homework question - tutors are online