""" Goal/purpose: This is a debugging exercise to be solved in class. The program attempts to sum the numbers 0.1 through 0.9, in steps of 0.1 The correct answer is 4.5, but neither loop finds it. (1) Why don't the loops terminate when we want them to? (2) Replace the conditionals in the two while statements so the loops end right after adding 0.9 into the sum. (There are lots of ways to do this.) Consider using the debugger to run the script with a breakpoint set inside the second loop. Author: George Gollin File: unit03_in_class_warmup.py Date: June 8, 2017 Physics 298 owl, University of Illinois at Urbana-Champaign """ print("\nthe correct answer is 4.5") # Define and initialize variables, then loop sum = 0.0 term = 0.1 increment = 0.1 last_term = 0.9 # here's the loop while term != last_term + increment: sum = sum + term term = term + increment if term > 100000: print("uh oh, first loop didn't terminate, so breaking now...") break # End of loop. Print the results. print("first loop result... sum is ", sum) # try again. Initialize variables, then do the loop sum = 0.0 term = 0.1 while term < last_term + increment: sum = sum + term term = term + increment # set a breakpoint at this line # End of loop. Print the results. print("second loop result... ", sum) # all finished.