Age-Calc / app.py
Rida-Zehra's picture
Create app.py
a349612 verified
raw
history blame contribute delete
518 Bytes
import streamlit as st
from datetime import datetime, date
st.set_page_config(page_title="Age Calculator", page_icon="πŸŽ‚")
st.title("πŸŽ‚ Age Calculator")
st.write("Enter your date of birth to calculate your age.")
dob = st.date_input("Select your Date of Birth", min_value=date(1900, 1, 1), max_value=date.today())
if st.button("Calculate Age"):
today = date.today()
age_years = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day))
st.success(f"You are {age_years} years old.")