jonasneves commited on
Commit
37c163b
Β·
verified Β·
1 Parent(s): ec13f9e

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +82 -38
src/streamlit_app.py CHANGED
@@ -1,40 +1,84 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
  import streamlit as st
5
 
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ # App title
4
+ st.title("πŸ“š Student Mood Grade Tracker")
5
+ st.write("*How does your grade affect your mood? Let's find out!*")
6
+
7
+ # Grade slider
8
+ grade = st.slider("Select your grade:", 0, 100, 85, help="Move the slider to see how your mood changes!")
9
+
10
+ # Define mood mappings
11
+ def get_mood_data(grade):
12
+ if grade >= 95:
13
+ return "🀩", "ECSTATIC", "#00ff00", "I'm basically a genius!"
14
+ elif grade >= 90:
15
+ return "😁", "THRILLED", "#32cd32", "Time to celebrate!"
16
+ elif grade >= 85:
17
+ return "😊", "HAPPY", "#90ee90", "Pretty good, I'm satisfied!"
18
+ elif grade >= 80:
19
+ return "πŸ™‚", "CONTENT", "#ffff99", "Not bad, could be worse"
20
+ elif grade >= 75:
21
+ return "😐", "MEH", "#ffa500", "It's... acceptable I guess"
22
+ elif grade >= 70:
23
+ return "πŸ˜•", "DISAPPOINTED", "#ff6347", "Ugh, I expected better"
24
+ elif grade >= 65:
25
+ return "😟", "WORRIED", "#ff4500", "This is concerning..."
26
+ elif grade >= 60:
27
+ return "😨", "PANICKED", "#ff0000", "I need to study MORE!"
28
+ else:
29
+ return "πŸ’€", "DEAD INSIDE", "#8b0000", "Time to change majors"
30
+
31
+ # Get current mood data
32
+ emoji, mood, color, message = get_mood_data(grade)
33
+
34
+ # Display the result with styling
35
+ st.markdown("---")
36
+
37
+ # Create columns for better layout
38
+ col1, col2, col3 = st.columns([1, 2, 1])
39
+
40
+ with col2:
41
+ # Large emoji display
42
+ st.markdown(f"<div style='text-align: center; font-size: 100px;'>{emoji}</div>",
43
+ unsafe_allow_html=True)
44
+
45
+ # Mood text with color
46
+ st.markdown(f"<h2 style='text-align: center; color: {color};'>{mood}</h2>",
47
+ unsafe_allow_html=True)
48
+
49
+ # Grade display
50
+ st.markdown(f"<h3 style='text-align: center;'>Grade: {grade}%</h3>",
51
+ unsafe_allow_html=True)
52
+
53
+ # Mood message
54
+ st.markdown(f"<p style='text-align: center; font-style: italic; font-size: 18px;'>'{message}'</p>",
55
+ unsafe_allow_html=True)
56
+
57
+ # Add some fun statistics
58
+ st.markdown("---")
59
+ st.subheader("πŸ“Š Mood Statistics")
60
+
61
+ col1, col2, col3 = st.columns(3)
62
+
63
+ with col1:
64
+ st.metric("Happiness Level", f"{min(grade, 100)}%")
65
+
66
+ with col2:
67
+ stress_level = max(0, 100 - grade)
68
+ st.metric("Stress Level", f"{stress_level}%")
69
+
70
+ with col3:
71
+ coffee_needed = max(0, (100 - grade) // 10)
72
+ st.metric("Coffees Needed", f"{coffee_needed} β˜•")
73
+
74
+ # Motivational section
75
+ st.markdown("---")
76
+ if grade < 70:
77
+ st.warning("🎯 **Study Tip**: Remember, every expert was once a beginner. You've got this!")
78
+ elif grade < 85:
79
+ st.info("πŸ’ͺ **Keep Going**: You're doing well! A little more effort can make a big difference.")
80
+ else:
81
+ st.success("🌟 **Amazing Work**: You're crushing it! Keep up the excellent work!")
82
+
83
+ # Fun footer
84
+ st.markdown("---")