Def income(): while True: try: income = input('What is your current annual income? Skype for ipad 1st gen. ') income = int(income) break except ValueError: print('Please only enter numbers') return income def homeowner(): yes = set(['y', 'Y', 'ye', 'yes', 'Yes', 'yeah']) no = set(['n', 'N', 'no', 'No', 'nope']) 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? Simplest programming tutorials for beginners. Python Function Arguments. Python User-defined Functions. Source Code: Simple Caculator by Making Functions. # Program make a simple calculator that can add, subtract, multiply and divide using functions #. Hi, I'm stuck with Area Calculator in Python. When the program runs and asks me to type 'C' or 'T', I type 'c' in order to check whether my.upper function works, but it keeps telling me 'NameError: name 'c' is not defined'. But I'm not supposed to define lowercase 'c' because it must automatically be.
0 Comments
Leave a Reply. |