Naz786 commited on
Commit
3cd3bfc
Β·
verified Β·
1 Parent(s): 060f29b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from datetime import date
3
+
4
+ def calculate_age(birth_date):
5
+ today = date.today()
6
+ age = today.year - birth_date.year - (
7
+ (today.month, today.day) < (birth_date.month, birth_date.day)
8
+ )
9
+ return age
10
+
11
+ def main():
12
+ st.set_page_config(page_title="Age Calculator", page_icon="πŸŽ‚")
13
+ st.title("πŸŽ‰ Age Calculator")
14
+ st.markdown("Enter your birthdate to calculate your age.")
15
+
16
+ birth_date = st.date_input("Select your birthdate")
17
+
18
+ if st.button("Calculate Age"):
19
+ age = calculate_age(birth_date)
20
+ st.success(f"Your age is: **{age}** years")
21
+
22
+ if __name__ == "__main__":
23
+ main()