Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Exercise 3 In Lab 3, you wrote Python code that calculates the amount of money you'11 have when money is deposited in a bank account

image text in transcribed

Exercise 3 In Lab 3, you wrote Python code that calculates the amount of money you'11 have when money is deposited in a bank account that earns interest. In this exercise, you'11 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: amount=principal(1+nrate)ntime 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: amount=$1,500(1+40.043)46$1938.84 Step 1: Below the comment, \# Exercise 3, type this function header: def accumulated_amount(principal: float, rate: float, n : int, time: int) float: Step 2: Use the function design recipe presented in the textbook and lectures to complete the function definition. You've been provided with the function header, but must write a complete docstring and the function body. One docstring example should use the values shown above ( $1,500 invested at 4.3% for 6 years, interest compounded four times a year). Other possible 4 examples include: what value would you expect the function to return if the principal is $0 ? If the interest rate is 0% ? Step 3: Save the code, then click Run. Correct any syntax errors. Step 4: Use the shell and your docstring examples to test accumulated_amount

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students explore these related Databases questions

Question

Define organisational structure

Answered: 3 weeks ago

Question

Define line and staff authority

Answered: 3 weeks ago

Question

Define the process of communication

Answered: 3 weeks ago