I have to write a python program for an intro comp sci class that finds simple interest, compound interest, and the future value of a simple annuity. This is easy- however I have to do it in way that is harder. Rather than just use the formula with exponents, I have to use a for loop to feed the value of each period back into itself.
For example, I did the compound interest part:
Code:
elif x in ['C', 'c']:
print("You have chosen compound interest.")
I=eval(input("Please enter the interest rate per period. "))
P=eval(input("Please enter the principal amount. "))
N=eval(input("Please enter the number of compounding periods. "))
for i in range (0, N):
P=P*(1.0+ (I/100))
print("The final amount is ", P)
I'm just not sure how to rearrange this:
Code:
elif x in ['A', 'a']:
print("You have chosen simple annuity.")
I=eval(input("Please enter the interest rate per period. "))
N=eval(input("Please enter the number of periods. "))
P=eval(input("Please enter the amount paid per period. "))
Y=(P*((((1+(I/100))**N)-1)/(I/100)))
print("The future value of the annuity is ", Y)
into a for loop. I was a Biology and Environmental Science major so this is all new to me =(