Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 3 In Lab 2, you wrote Python code that calculates the amount of money you'll have when money is deposited in a bank account
Exercise 3 In Lab 2, you wrote Python code that calculates the amount of money you'll have when money is deposited in a bank account that earns interest. In this exercise, you'll reimplement this code as a function. Suppose you have some money (the principal) that is deposited in a bank account for a number of years and earns a fixed annual rate of interest. The interest is compounded n times per year. The formula for determining the amount of money you'll have is: n x time amount = principal(1 + rate)" where: amount is the amount of money accumulated after time years, including interest. principal is the initial amount of money deposited in the account rate is the annual rate of interest, specified as a decimal; e.g, 5% is specified as 0.05 n is the number of times the interest is compounded per year time is the number of years for which the principal is deposited. . For example, if $1,500.000 is deposited in an account paying an annual interest rate of 4.3%, compounded quarterly (4 times a year), the amount in the account after 6 years is: 4 x 6 0.043 ~$1938.84 4 amount = $1,500(1 + 0,043) Step 1: Create a new editor window and save it. Use lab3ex3.py as the file name. Step 2: Type this function header: def accumulated_amount(principal, rate, n, time): Complete the function definition. Step 3: Save the code, then click Run. Correct any syntax errors. Step 4: Test your function by typing call expressions in the shell. Verify that your function returns the correct value for the example shown above. You should also test other cases. For example, what value would you expect the function to return if the principal is $0? If the interest rate is 0%? Does your function return correct values for these test cases? Step 5: Close the editor window for lab3ex3.py
Step 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