Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from datetime import datetime, date
|
| 3 |
+
|
| 4 |
+
st.title("Age Calculator")
|
| 5 |
+
|
| 6 |
+
birthdate = st.date_input("Select your birthdate:")
|
| 7 |
+
|
| 8 |
+
if st.button("Calculate Age"):
|
| 9 |
+
today = date.today()
|
| 10 |
+
age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day))
|
| 11 |
+
st.success(f"You are {age} years old.")
|