Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The idea behind compound interest is that when interest is applied to some base

ID: 3728019 • Letter: T

Question

The idea behind compound interest is that when interest is applied to some base amount regularly over a given time period, each interest payment increases the base amount, so that the next interest payment is calculated against the increased base amount. For example, say you have a $1000 savings bond that matures in 10 years. The first year it earns $100 interest (10% of $1000). This interest is added to the base amount (S 1000 + S 100-> SI 100). The second year the bond earns $110 interest (10% of si 100), and the base increases to S1210 (S1100 + SI 10-> SI 210); and so on. After 10 years, the bond grows to $2593.74. Implement the following function using a while loop. Provide appropriate assertions. def compound(base, percent, time): Determines total cost of a loan. Preconditions: base - principle amount to apply interest to (float 0) percent percent change applied to base (float 0) time time period for change (int + 0) Postconditions: returns final - total amount of a principle with compound interest added.

Explanation / Answer

''' To solve this first you need to use assert statement to check conditions Assert statement raise exception when condition inside it is false. So I included 3 assert condition for 3 variables I did not add data type check for base and percent because we are passing them as integer If you want to check then pass them as 1000.0 , 10.0 so their data type will be float and you can check them easily After that you can calculate compound interest by calculating simple interest on compound amount steps : year=1 (1) Run a while loop => while(year