# app.py import streamlit as st from datetime import date, datetime # Page settings st.set_page_config(page_title="Age Calculator", page_icon="🎂", layout="centered") # Title st.title("🎂 Age Calculator") st.markdown("Enter your birthdate below to calculate your current age.") # Input birth_date = st.date_input("📅 Select your birthdate", min_value=date(1900, 1, 1), max_value=date.today()) # Button if st.button("Calculate Age"): today = date.today() # Age in years age_years = today.year - birth_date.year - ( (today.month, today.day) < (birth_date.month, birth_date.day) ) # Age in months and days delta = today - birth_date age_days = delta.days age_months = age_days // 30 # Output st.success(f"🎉 You are **{age_years} years** old.") st.info(f"📆 That's approximately **{age_months} months** or **{age_days} days** old.") # Birthday message if today.month == birth_date.month and today.day == birth_date.day: st.balloons() st.markdown("🎈 **Happy Birthday!** 🎁🎉") # Footer st.markdown("---") st.markdown("Made with ❤️ using Streamlit")