Question: In TODO 7 , you will implement the simulate_account_balance function. The function has the following parameters: init_principal: A float indicating the initial principal balance. acc_rate:

In TODO 7, you will implement the simulate_account_balance function. The function has the following parameters:

init_principal: A float indicating the initial principal balance.

acc_rate: A float indicating the interest rate per year (e.g., 0.05 for 5%).

acc_cmp_freq: An int indicating the number of times interest is applied per year.

setup_fee: A float indicating the amount of dollars that is deduced from the init_principal when the account is set up (you only deduct once).

years: An int indicating the number of years for which we would like to run the report.

Based on the provided arguments, the function will print one or more lines each of which displays two values - year number (starting from 2) and current balance on the account - separated by a space.

Let us go over the details of how the function works using the following example arguments:

init_principal: 10000.00

acc_rate: 0.025

acc_cmp_freq: 12

setup_fee: 25.00

years: 10

Overall, the simulate_account_balance function implements the loop that prints the balance on the account each two years. Note that;

The first row should show the balance after 2 years.

The last row should show the balance after the number of years specified under years (or years - 1 if the years argument is an odd number).

We suggest you implement the function in the following flow:

Define a loop that executes years / 2 times assigning the year variable with the even numbers 2, 4, etc. HINT: Consider using the Python in-built range class.

Within each iteration, compute the balance on the account (using the compound_interest function you implemented earlier), and print the year variable and the balance on the account rounded to 2 decimal places.

For example, we get the following lines for; Year 2:

 2 10485.88 # compound_interest(9975.00, 0.025, 12, 2) -> 10485.88 

Year 4:

 4 11022.93 # compound_interest(9975.00, 0.025, 12, 4) -> 11022.93 

Year ...:

 ... (etc.) 

HINT: For rounding, you may use the Python in-built round function.

>>> round(1.2345, 2) 1.23 >>> round(1.2001, 2) 1.2 

Attention

Be careful to properly account for the setup_fee. Think carefully about the point in time when the fee is applied.

You are encouraged to validate your implementation by placing a call to the simulate_account_balance function as; simulate_account_balance(10000.00, 0.025, 12, 25.00, 10)

The expected output of running the file would then be:

2 10485.88 4 11022.93 6 11587.49 8 12180.96 10 12804.82 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock