Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 3 : Suppose you have some money ( the principal ) that is deposited in a bank account for a number of years and

Exercise 3: 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 will have is:
amount = principal (1+raten)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, and not 5.
i 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 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 =$1500(1+0.0434)46~~$1938.84
In PyTutor, click'Edit this code. Delete the code in PyTutor's editor, then:
Type four assignment statements that create new variables named principal, rate, n and time, and assign them the values 1500,0.043,4 and 6 respectively.
Type one assignment statement that calculates the amount of money in the account after time years, using the formula presented above. This value should be assigned to a new variable named amount. Your assignment statement must demonstrate the use of the Python built-in function pow.
Click the Visualize Execution button. Execute the code, one statement at a time, and observe the memory model as the code is executed, step-by-step. Verify that the accumulated amount of money is approximately 1938.84.
When your code is correct, copy/paste the five assignment statements from PyTutor into lab3.txt.
image text in transcribed

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions