Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- 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 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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("---")
|