#Code : Age checks how long you have lived so far from the number of years you have lived by: https://t.me/DevMuhamed
print("Hello in my project,\nAbout: Age calculator for humans", end="\n\n")
gender = input("Plese enter your gender Male/Female (M/F): ").capitalize().strip()
username = input("Please enter your name: ").strip().capitalize()
if username.isalpha() and len(username) >= 3 :
if gender == "Male" or gender == "M" :
print("\nWelcome, Mr {}".format(username) , end="\n\n")
elif gender == "Female" or gender == "F" :
print("\nWelcome, Miss {}".format(username) , end="\n\n")
else:
print("\nWelcome, Gay {} \nWe don't know your gender, whether male or female or not.\nSo we will determine your gender, which is gay.".format(username) , end="\n\n")
try:
from datetime import datetime
numAge = input("1=> ( 18 Years => 18 ) or 2=> (YYYY/MM/DD => 2002/12/5 )\nI recommend the second method because it brings back life accurately.\n\nNow please enter your age: ")
age = numAge
if age.isdigit() > 0 :
years = int(age)
months = years * 12
days = months * 30
hours = days * 24
minutes = hours * 60
seconds = minutes * 60
print("U have lived about:")
print("\tYour years: {}\n\tYour months: {}\n\tYour days: {}\n\tYour hours: {}\n\tYour mintues: {}\n\tYour seconds: {}".format(years,months,days,hours,minutes,seconds))
elif age :
age = datetime.strptime(age , "%Y/%m/%d")
now = datetime.today()
years = now.year - age.year
months = now.month - age.month
days = now.day - age.day
if days < 0:
months -= 1
days += (age.replace(month=age.month % 12 + 1, day=1) - age.replace(day=1)).days
if months < 0:
years -= 1
months += 12
hours = (days * 24) + (((years * 12 ) * 30 ) * 24) +((months * 30) * 24)
minutes = hours * 60
seconds = minutes * 60
print("\tYour date of birth: Year: {}\tMonth: {}\tDay: {}\n\t'U have lived about:'\n\t Your years: {}\n\t Your months: {}\n\t Your days: {}\n\t Your hours: {}\n\t Your mintues: {}\n\t Your seconds: {}".format(years,months,days,years,((years * 12) + months),(((years * 12) + months) * 30 ),hours,minutes,seconds))
else:
print("Who are you man/woman/gay?")
except ValueError:
print("Could you write a number or ( YYYY/MM/DD ), please?")
else:
print("Please enter a valid name.")