Age_Calculator / app.py
Muqadas-13's picture
Create app.py
02771a7 verified
raw
history blame contribute delete
562 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.markdown("Enter your birthdate below to calculate your age:")
birthdate = st.date_input(
"Select your birthdate",
min_value=date(1900, 1, 1),
max_value=date.today()
)
if st.button("Calculate Age"):
today = date.today()
age = today.year - birthdate.year - (
(today.month, today.day) < (birthdate.month, birthdate.day)
)
st.success(f"Your age is: **{age}** years")