![]() Making A Calculator In Python def income(): while True: try: income = input('What is your current annual income? ') income = int(income) break except ValueError: print('Please only enter numbers') return income def homeowner(): yes = set() no = set() homeowner = None while True: homeownerchoice = input('Do you own or intend to own your property by retirement age? (y/n)') if homeownerchoice in yes: homeowner = True break elif homeownerchoice in no: homeowner = False break else: print ('Please answer yes or no') return homeowner def housecost(h): while True: if h False: try: housecost = input ('How much does your rent or mortgage cost each month? ') housecost = int(housecost) break except ValueError: print ('Please only enter numbers') else: housecost = 0 break return housecost def bills(): while True: try: billcost = input('What is the combined monthly cost of your bills, not including Rent or Mortgage? n(i.e Electric, Gas, Water, Cable, Phone, etc) ') billcost = int(billcost) break except ValueError: print('Please only enter numbers') return billcost def age(): while True: try: userage = input('How old are you currently? ') userage = int(userage) break except ValueError: print('Please only enter numbers') while True: try: retiredage = input('At which age do you plan to retire? ') retiredage = int(retiredage) break except ValueError: print('Please only enter numbers') return (userage, retiredage) def pension(): while True: try: pension = input('How much do you currently have saved for retirement? (Pension or otherwise) ') pension = int(pension) break except ValueError: print('Please only enter numbers') return pension income = income() homeowner = homeowner() housecost = housecost(homeowner) bills = bills() userage, retiredage = age() pension = pension() def main(inc, hom, hcost, bil, uage, rage, pen): ageDiff = rage - uage lifeEx = retirement = - rage), (lifeEx - rage), (lifeEx - rage)] lifeBills = * (bil + hcost) * 12), (retirement * (bil + hcost) * 12), (retirement * (bil + hcost) * 12)] reqMoney = - pen), (lifeBills - pen), (lifeBills - pen)] monthlySave = / ageDiff) / 12), ((reqMoney / ageDiff) / 12), ((reqMoney / ageDiff) /12)] incomePercent = / inc) * 1200), ((monthlySave / inc) * 1200), ((monthlySave / inc) * 1200)] print('n Assuming you retire at age', rage, 'you will need to save the following, based on how long you live: ') x = 0 for i in lifeEx: print ('nIf you live until', lifeEx, 'you will need to save an additional', round(reqMoney)) print ('nThis means that as of now, you need to save:') print(round(monthlySave), 'per month, up until you retire') print('That is', incomePercent, 'percent of your annual salary') x = x + 1 print ('nThis sum does not account for the cost of eating, or travelling or leisure, so you will need save more with that considered. Obviously the outcome will depend on the actual returns the portfolio achieves but you, in conjunction with your adviser, will need to make assumptions about the earning rate on your portfolio and the rate of inflation if you. Main (income, homeowner, housecost, bills, userage, retiredage, pension ) This calculator will help you to get an idea of how long your portfolio will last after you retire. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |