Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please note that we have to add amount 100 into the account every month instead of only 100 from the begging to the end. THANK
Please note that we have to add amount 100 into the account every month instead of only 100 from the begging to the end.
THANK YOU !!!! Please use while loop instead of for loop
PLEASE ONLY WRITE THE SECOND (SAVINGBYMONTH) CODE
Applications : Continuously Compounded Interest Suppose we decide to invest some money in an account that continously compounds interest. In other words, the amount that we initially invested is constantly earning interest and any interest that we earned also keeps acquiring interest. At first, let's compute our earnings in the short term. Suppose you save $100 each month into a savings account that has an annual interest rate of 5%. So, the monthly interest rate is 0.05/12 = 0.00417. After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417 After the second month, the value in the account becomes (100 + 100.417) *(1 +0.00417) = 201.252 After the third month, the value in the account becomes (100+ 201.252) * (1+0.00417) = 302.507 and so on. Before you begin writing any code, try writing out the pseudocode for your function. Think about how you would calculate the compound interest if you did the math by hand and use this to help you in the implementation. Write a function savings that computes and returns the savings amount after the given month, given a monthly contribution amount (e.g., 100), the annual interest rate (e.g., 5), and the number of months (e.g., 6), Use the while loop to implement this function. def savings (amount, interest rate, months): Given a monthly contribution amount (e. 8., 100), the annual interest rate (e.g., 5), and the number of months (e.g., 6), returns the savings amount after the given month. return "stub" # TODO: replace return "stub" with a correct return statement Now, write a new function savings ByMonth() that will save each month's savings as a new element in the list, which gets returned from the function. So, in the example above, the list would have the initial amount stored as the first element, 100.417 as the second element, etc. def savingsByMonth(amount, interest_rate, months): Given a monthly contribution amount (e.g., 100), the annual interest rate (e.g., 5), and the number of months (e. g., 6), returns a list with the savings amount for each month, including the initial amount as the first element, and the savings in the given month as the last element. return "stub" # TODO: replace return "stub" with a correct return statement Now that you have the list, you can switch to your lab04_plot.py and use the matplotlib package to visualize the earningsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started