Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from datetime import date
|
3 |
+
|
4 |
+
st.set_page_config(page_title="Age Calculator", layout="centered")
|
5 |
+
st.title("π Age Calculator")
|
6 |
+
st.subheader("Calculate your age from your date of birth")
|
7 |
+
|
8 |
+
dob = st.date_input("π
Select your Date of Birth", value=date(2000, 1, 1))
|
9 |
+
calculate = st.button("π’ Calculate Age")
|
10 |
+
clear = st.button("ποΈ Clear")
|
11 |
+
|
12 |
+
if calculate:
|
13 |
+
today = date.today()
|
14 |
+
age_years = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day))
|
15 |
+
st.success(f"π You are {age_years} years old!")
|
16 |
+
|
17 |
+
if clear:
|
18 |
+
st.experimental_rerun()
|