123456789101112131415161718192021222324252627282930313233343536 |
- # Copyright (C) 2020, 2019 Prince Rashid
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- #
- '''
- Create a program that asks the user to enter their name and their age.
- Print out a message addressed to them that tells them the year that they will turn 100 years old.
- '''
- # @author prince
- import datetime
- n = input('Enter your age. I will tell you when you would turn 100 years old: ')
- n = int(n)
- currentYear = int(datetime.datetime.now().year)
- an = ((currentYear - n)+100)
- if n < 0:
- print('invalid number')
- elif n > currentYear:
- print("Congrats! you are a centurian! You turned 100 in", abs(an), "BC")
- elif n > 100:
- print("Congrats! you are a centurian! You turned 100 in", an)
- else:
- print("you will turn 100 in: ", an)
|