215k views
5 votes
Let r be a bank's interest rate in percent per year (APR). An initial amount of money P, also called as principal, will mature to an amount of P(1+r/100)^n after n years have passed. Write a Python program that takes P, r, and n as inputs from the user and provides as output the matured value after n years. For example if the user provides P, r, and n as 1000 0.95 and 5 .Your program must apply the interest-rate formula and provide 1048.4111145526908 as the output.

User Tkone
by
3.9k points

1 Answer

5 votes

Answer:

See explanation below.

Step-by-step explanation:

For this case the program needs to take the inputs as P,r and n and the output would be as A and printed on the system. The code is:

# Inputs

P = float(input("Enter the present value : "))

r = float(input("Enter your APR : "))

n = float(input("Enter the number of years : ") )

# Output

A = P*(1 +(r/100))**n

print("The future values is:", A)

And the result obtained is:

Enter the present value : 1000

Enter your APR : 0.95

Enter the number of years : 5

The future values is: 1048.4111145526908

User Ashir
by
4.9k points