KZTech commited on
Commit
a25fc13
Β·
verified Β·
1 Parent(s): 6842045

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
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()