Expand|Select|Wrap|Line Numbers
- # futval.py
- # A program to compute the value of an investment
- # carried 10 years into the future
- def main():
- print "This program calculates the future value"
- print "of a 10 year investment."
- principal = input("Enter the initial principal: ")
- apr = input("Enter the annualized interest rate: ")
- for i in range(10):
- principal = principal * (1 + apr)
- print "The value in 10 years is:", principal
- main()
This program calculates the future value
of a 10 year investment.
Enter the initial principal: 1000
Enter the annualized interest rate: .1
The value in 10 years is: 2593.7424601
but i need to get an output like this as below
This program calculates the future value
of a 10 year investment.
Enter the initial principal: 1000
Enter the annualised interest rate: .1
Year Value
----------------
0 1100.00
1 1210.00
2 1331.00
3 1464.10
4 1610.51
5 1771.56
6 1948.72
7 2143.59
8 2357.95
9 2593.74
The value in 10 years is: 2593.74
so i would be thankful if anybody could help me out as i am new to python