import os, sys # https://www.investopedia.com/terms/t/timevalueofmoney.asp # Formula for Time Value of Money # FV = PV x [1 + (i / n)]^(n x t) # Assume a sum of $10,000 is invested for one year at 10% interest compounded annually. # The future value of that money is: # FV = $10,000 x [1 + (10% / 1)] ^ (1 x 1) = $11,000 compounding_periods = {"annual" : 1, "monthly" : 12, "quarterly" : 4, "daily" :365} if 'INVESTMENT' not in os.environ: print("Cannot run the script. Investment is missing.") sys.exit() if 'INTEREST_RATE' not in os.environ: print("Cannot run the script. Interest rate is missing.") sys.exit() if 'COMPOUNDING_PERIOD' not in os.environ: print("Cannot run the script. Compounding period is missing.") sys.exit() if 'YEARS' not in os.environ: print("Cannot run the script. Number of years are missing.") sys.exit() compounding_period = os.getenv('COMPOUNDING_PERIOD') if compounding_period not in compounding_periods.keys(): print("Cannot run the script.", compounding_period," is not a valid period") sys.exit() investment = int(os.getenv('INVESTMENT')) interest_rate = float(os.getenv('INTEREST_RATE')) years = int(os.getenv('YEARS')) n = compounding_periods[compounding_period] FV = investment * pow((1 + ((interest_rate/100) / n)),n * years) print("Assume a sum of",investment,"is invested for",years,"year(s) at",interest_rate,"% interest compounded on",compounding_period,"basis. ") print("The future value of that money is:") print(FV)