Spaces:
Sleeping
Sleeping
File size: 646 Bytes
3cd3bfc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import streamlit as st
from datetime import date
def calculate_age(birth_date):
today = date.today()
age = today.year - birth_date.year - (
(today.month, today.day) < (birth_date.month, birth_date.day)
)
return age
def main():
st.set_page_config(page_title="Age Calculator", page_icon="π")
st.title("π Age Calculator")
st.markdown("Enter your birthdate to calculate your age.")
birth_date = st.date_input("Select your birthdate")
if st.button("Calculate Age"):
age = calculate_age(birth_date)
st.success(f"Your age is: **{age}** years")
if __name__ == "__main__":
main()
|