Answers for "python calculate age from date"

7

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))
Posted by: Guest on April-17-2021
3

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)
Posted by: Guest on June-21-2021
0

method for format age in python

def format_age(s):
    chars = list(s)  # list of characters
    digit_chars = [c for c in chars if c.isdigit()]
    return int("".join(digit_chars))
Posted by: Guest on January-07-2021

Code answers related to "python calculate age from date"

Python Answers by Framework

Browse Popular Code Answers by Language