Write a program to calculate the value of an investment for 10 years in the future :
This is a python program to calculate the value of investment for 10 years in the future.
In order to do this exercise, first we need to get the initial investment and the annual rate
of the user. As usual as we did in the previous exercise we will use the eval method to get the desired variable type.
Now, it’s time to calculate the investment for 10 years.
Tips to follow :
Get the initial investment.
Get the annual rate.
Compute the investment for 10 years using the formula - investment = investment * (1 + annual_rate).
Print the investment.
Investment for 10 years in the future :Write a program to calculate the value of an investment for 10 years in the future :
This is a python program to calculate the value of investment for 10 years in the future.
In order to do this exercise, first we need to get the initial investment and the annual rate
of the user. As usual as we did in the previous exercise we will use the eval method to get the desired variable type.
Now, it’s time to calculate the investment for 10 years.
Tips to follow :
Get the initial investment.
Get the annual rate.
Compute the investment for 10 years using the formula - investment = investment * (1 + annual_rate).
Print the investment.
Video explanation :
Investment for 10 years in the future :
# Write a program to calculate the value of an investment for 10 years in the future
print("This program calculates the future value of a 10-year investment.")
investment = eval(input("Enter initial investment:"))
annual_rate = eval(input("Enter the annual interest rate:"))
for i in range(10):
investment = investment * (1 + annual_rate)
print("The value in 10 years is:", investment)
Investment for 10 years in the future using Functions:
# Write a program to calculate the value of an investment for 10 years in the future using functions
def investment():
print("This program calculates the future value of a 10-year investment.")
investment = eval(input("Enter initial investment:"))
annual_rate = eval(input("Enter the annual interest rate:"))
for i in range(10):
investment = investment * (1 + annual_rate)
print("The value in 10 years is:", investment)
investment()
Post a Comment
0Comments