# # computes approximately how many days # you have lived w/o considering partial # or leap years. # # shows use of CONSTANT and string function # # example of basic while-loop and if-statement # # written by e.bonakdarian oct 2009 # from string import capitalize DAYS_IN_YEAR = 365 print 'Program will compute approximately how old you are in days' print '(without considering partial or leap years)' print stop = False while (not stop): name = raw_input('What is your name? ') age = input('How old are you (in years)? ') if age >= 1: days_lived = age * DAYS_IN_YEAR print ('Dear %s, you are approximately %d days old.' % (capitalize(name), days_lived)) else: print ('\nYou entered "%d" for age.' % age) # note blank line print ('Please enter a value >= 1') # specific/helpful error msg answer = raw_input('\nEnter "x" to stop: ') if answer.lower() == 'x': # note use of string functions stop = True print '\nEnding program\n' raw_input('\n to exit')