Chapter 2: Problem 16
interest rate amount = initial_amount years = 0 while amount <= 1.5*init… # Consider the following program for computing with interest rates: initial_amount = 100 p = 5.5 # interest rate amount = initial_amount years = 0 while amount <= 1.5*initial_amount: amount = amount + p/100*amount years = years + 1 print years (a)Explain with words what type of mathematical problem that is solved by this program. Compare this computerized solution with the technique your high school math teacher would prefer. (b)Use a pocket calculator (or use an interactive Python shell as substitute) and work through the program by hand. Write down the value of amount and years in each pass of the loop. (c) Change the value of \(p\) to 5 . Why will the loop now run forever? (See Exercise \(2.12\) for how to stop the program if you try to run it.) Make the program more robust against such errors. (d)Make use of the operator += wherever possible in the program. Insert the text for the answers to (a) and (b) in a multi-line string in the program file. Name of program file: interest_rate_loop.py.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.