Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python calculate age from date of birth

from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
Comment

age calculator in python

import datetime 
Year_of_birth = int(input("In which year you took birth:- "))
current_year = datetime.datetime.now().year
Current_age = current_year - Year_of_birth
print("Your current age is ",Current_age)
Comment

Calculate age python

from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
Comment

python calculate age from date of birth

#Python Calculate Age from date of birth:

from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
Comment

age calculator in python


from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))

Comment

age calculator python

import datetime
def Age_Calculator():
    '''create a python function that takes user birth year & month & day and prints
how old he is
args:name,birthday,birthmonth,birthyear
return : current age in years&monthand days
'''
    name = input("please enter your name :".title())
    today = datetime.date.today()
    birthday, birthmonth, birthyear = int(input("enter your bithday : ".title())), int(
        input("enter your bithmonth : ".title())), int(input("enter your bithyear : ".title()))
    # input birth year& month and day
    my_age_year, my_age_month, my_age_day = abs(
        today.year-birthyear), abs(today.month-birthmonth), abs(today.day-birthday)
    # get current age from today-my_birthdate
    nex_birthdate = datetime.date(today.year+1, birthmonth, birthday)
    #birth date in next year
    num_day = nex_birthdate-today
    print(
        f"congratulations {name} your age is {my_age_year} years & {my_age_month} month and {my_age_day} days".title())
    print(
        f"congratulations {name} your next birthdate after {num_day.days} days ".title())
Age_Calculator()
Comment

AGE CALCULATOION IN PYTHON

#AGE CALCULATOION IN PYTHON:

def calculator(age):
    age = (2022 - int(age))
    print("You are "+str(age)+" years Old")
calculator(input("Type your Birth Year: "))

#The easy way to calculate anyones age.Very simple trick.
# Just call a function
Comment

PREVIOUS NEXT
Code Example
Python :: create json list of object to file python 
Python :: program to calculate the volume of sphere python 
Python :: virtualenv -p python3 
Python :: python clear screen 
Python :: how to add row to the Dataframe in python 
Python :: convert all values in array into float 
Python :: selenium quit browser python 
Python :: how to read zip csv file in python 
Python :: how to add an active class to current element in navbar in django 
Python :: token_obtain_pair check email 
Python :: python save string to text 
Python :: print on two digit python format 
Python :: how to set google chrome as default browser when coding with python using webbroiwser module 
Python :: Removing punctuation in Python 
Python :: sqlite3 like python 
Python :: import settings 
Python :: Not getting spanish characters python 
Python :: how to print the text of varying length in python 
Python :: python concat list to sql query string 
Python :: pause program python 
Python :: Python Time object to represent time 
Python :: python get words between two words 
Python :: absolut beginners projects in python with tutorial 
Python :: python is not writing whole line 
Python :: python to exe 
Python :: import c# dll in python 
Python :: read csv boto3 
Python :: array must not contain infs or NaNs 
Python :: python get ip info 
Python :: upload multiple files streamlit 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =