Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main(): #The main function
- print('Hello,\nI am going to ask you your name, and your age. ' +
- 'After that, I will tell you what year you were born, and what year you will turn 100!\n')
- #Local functions
- def get_age(): #Gets the age of the user
- age = input('Please enter your age: ')
- #Convert age into a number
- if str.isdigit(age):
- return int(age)
- else:
- print('Make sure you only enter numbers!\n')
- return get_age()
- #Get information
- name = input('Please enter your name: ')
- age = get_age()
- current_year = 2016
- birth_year = current_year - age
- years_till_hundred = 100 - age
- year_at_hundred = current_year + years_till_hundred
- print('Okay \'' + name + '\', we have everything done now.\n' +
- 'Your current age is: ' + str(age) + '\n' +
- 'Your birth year was: ' + str(birth_year) + '\n' +
- 'You have this many years until you turn 100: ' + str(years_till_hundred) + '\n' +
- 'You will turn 100 in: ' + str(year_at_hundred) + '\n')
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement