|
import streamlit as st |
|
|
|
|
|
st.markdown( |
|
""" |
|
<style> |
|
.stSlider label { |
|
font-size: 24px; /* Increase the font size of the slider label */ |
|
} |
|
.stTextInput label { |
|
font-size: 24px; /* Increase the font size for text inputs if needed */ |
|
} |
|
.stMarkdown { |
|
font-size: 24px; /* Increase the font size of text outputs */ |
|
} |
|
.css-1d391kg p { |
|
font-size: 24px; /* General output text font size */ |
|
} |
|
</style> |
|
""", |
|
unsafe_allow_html=True |
|
) |
|
|
|
|
|
x = st.text_input('Enter a value, and I\'ll guess your age!', '') |
|
|
|
def estimate_age_from_input(x): |
|
try: |
|
|
|
x = abs(float(x)) |
|
|
|
|
|
|
|
age_brackets = { |
|
(13, 17): 0.15, |
|
(18, 24): 0.25, |
|
(25, 34): 0.30, |
|
(35, 44): 0.15, |
|
(45, 54): 0.08, |
|
(55, 64): 0.05, |
|
(65, 100): 0.02 |
|
} |
|
|
|
|
|
if x > 1000000 or x < -1000000: |
|
|
|
return 18 |
|
elif x > 10000 or x < -10000: |
|
|
|
return 22 |
|
elif x == 69 or x == 420 or x == 80085: |
|
|
|
return 16 |
|
elif x == 0: |
|
|
|
return 25 |
|
elif x == 1: |
|
|
|
return 28 |
|
elif 1 <= x <= 100: |
|
|
|
if x <= 20: |
|
return 24 |
|
else: |
|
return min(int(x * 0.8 + 15), 75) |
|
else: |
|
|
|
import random |
|
brackets = list(age_brackets.items()) |
|
weights = [p for _, p in brackets] |
|
chosen = random.choices(brackets, weights=weights)[0][0] |
|
return random.randint(chosen[0], chosen[1]) |
|
|
|
except (ValueError, TypeError): |
|
|
|
return 19 |
|
|
|
|
|
if x: |
|
y = estimate_age_from_input(x) |
|
st.write(f'I think you\'re about {y} years old.') |
|
|
|
|