File size: 2,703 Bytes
e2a7b28
 
b1ea3a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40f4053
3739ad0
 
 
 
 
081bb82
3739ad0
 
 
 
 
 
 
 
 
 
 
081bb82
3739ad0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
081bb82
3739ad0
 
 
 
b1ea3a2
081bb82
 
b1ea3a2
e2a7b28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import streamlit as st

# Custom CSS to increase font size for input and output
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
)

# Use text input instead of slider
x = st.text_input('Enter a value, and I\'ll guess your age!', '')

def estimate_age_from_input(x):
    try:
        # Convert to float and get absolute value
        x = abs(float(x))

        # Base probability of different age groups (skewed young due to internet usage)
        # Roughly based on internet usage demographics
        age_brackets = {
            (13, 17): 0.15,  # Teens
            (18, 24): 0.25,  # Young adults
            (25, 34): 0.30,  # Early career
            (35, 44): 0.15,  # Mid career
            (45, 54): 0.08,  # Late career
            (55, 64): 0.05,  # Pre-retirement
            (65, 100): 0.02  # Retirement
        }

        # Adjust probabilities based on input value
        if x > 1000000 or x < -1000000:
            # Very large/small numbers - likely young person testing limits
            return 18
        elif x > 10000 or x < -10000:
            # Large numbers - probably young
            return 22
        elif x == 69 or x == 420 or x == 80085:
            # Meme numbers - likely teen/young adult
            return 16
        elif x == 0:
            # Default/lazy input - use median young adult age
            return 25
        elif x == 1:
            # Simple input - slight skew older
            return 28
        elif 1 <= x <= 100:
            # Reasonable number - use weighted distribution
            if x <= 20:
                return 24  # Young skew for small numbers
            else:
                return min(int(x * 0.8 + 15), 75)  # Scale up but cap at 75
        else:
            # Other numbers - use base distribution
            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):
        # Non-numeric input - assume young user testing system
        return 19

# Display the age estimation result
if x:
    y = estimate_age_from_input(x)
    st.write(f'I think you\'re about {y} years old.')