A Python debugger is paused immediately before the first statement below. Its variable inspector shows price = 6, quantity = 9, and discount = 7. Price and discount are in dollars; quantity is an item count.
subtotal = price * quantity total = subtotal - discount print(total)
In this debugger, Step Over executes the highlighted statement and pauses before the next one. After pressing Step Over exactly twice, what value will the inspector show for total? Answer in dollars, to zero decimal places. The initially highlighted statement has not yet executed.
Unlock full course notes by signing up
Organize a debugging investigation
A ticket-price program produces an incorrect total for a repeatable test input. You have recorded the expected total, confirmed the source file and interpreter, and set a breakpoint immediately before the suspected assignment. Arrange the remaining actions to inspect the values before and after that assignment, then verify a source-code correction.
Predict the pauses at a loop breakpoint
A student runs the program below in their IDE's debug mode. The only breakpoint is on the line total = total + i, and each time the program pauses the student reads the Variables pane, then presses Resume (Continue) to run on to the next breakpoint hit.
Complete the table with whole numbers: the values of i and total shown in the Variables pane at each pause, and their values when the print line runs after the loop.
Separate environment evidence from program evidence
An IDE can select either Python interpreter A or Python interpreter B. A helper library is installed for A, but it is unavailable to B. The Run configuration currently selects B and the intended saved source file. The program first imports the helper library, then calculates a bill. A breakpoint is set before the calculation.
The current run stops at the import with a library-not-found error, before reaching the breakpoint. The Shell also contains a successful bill from yesterday's run using A and different input. Which statements are supported by the evidence from the current run? Select all that apply.
Trace a breakpoint inside a called function
A student debugs the program below. The only breakpoint is on the line bonus = n // 10 inside score. They start the debugger and press Resume (Continue) after every pause until the program finishes.
Give each answer as a whole number:
how many times the program pauses on the breakpoint line;