Rewrite the given Python program such that it doesn't use the ** operator and also use a for-loop to compute r = b**n in the following way:
r = 1
for counter in range(n):
r = r * b
You may assume that n is always an int value.
Given Python Program:
The formula for computing the final amount if one is earning compound interest is given on Wikipedia as:
A = P * (1 + r/n)^(n*t)
Where:
P = principal amount (initial investment)
r = annual nominal interest rate (as a decimal)
n = number of times the interest is compounded per year
t = number of years
Write a Python program that assigns the principal amount of 10000 to variable P, assigns to n the value 12, and assigns to r the interest rate of 8% (0.08). Then have the program prompt the user for the number of years, t, that the money will be compounded for. Calculate and print the final amount after t years.
P = 10000
n = 12
r = 0.08
t = int(input("Compound for how many years? "))
final = P * (1 + r/n)**(n*t)
print("The final amount after", t, "years is", final)