mood-tracker / src /streamlit_app.py
jonasneves's picture
Update src/streamlit_app.py
37c163b verified
import streamlit as st
# App title
st.title("πŸ“š Student Mood Grade Tracker")
st.write("*How does your grade affect your mood? Let's find out!*")
# Grade slider
grade = st.slider("Select your grade:", 0, 100, 85, help="Move the slider to see how your mood changes!")
# Define mood mappings
def get_mood_data(grade):
if grade >= 95:
return "🀩", "ECSTATIC", "#00ff00", "I'm basically a genius!"
elif grade >= 90:
return "😁", "THRILLED", "#32cd32", "Time to celebrate!"
elif grade >= 85:
return "😊", "HAPPY", "#90ee90", "Pretty good, I'm satisfied!"
elif grade >= 80:
return "πŸ™‚", "CONTENT", "#ffff99", "Not bad, could be worse"
elif grade >= 75:
return "😐", "MEH", "#ffa500", "It's... acceptable I guess"
elif grade >= 70:
return "πŸ˜•", "DISAPPOINTED", "#ff6347", "Ugh, I expected better"
elif grade >= 65:
return "😟", "WORRIED", "#ff4500", "This is concerning..."
elif grade >= 60:
return "😨", "PANICKED", "#ff0000", "I need to study MORE!"
else:
return "πŸ’€", "DEAD INSIDE", "#8b0000", "Time to change majors"
# Get current mood data
emoji, mood, color, message = get_mood_data(grade)
# Display the result with styling
st.markdown("---")
# Create columns for better layout
col1, col2, col3 = st.columns([1, 2, 1])
with col2:
# Large emoji display
st.markdown(f"<div style='text-align: center; font-size: 100px;'>{emoji}</div>",
unsafe_allow_html=True)
# Mood text with color
st.markdown(f"<h2 style='text-align: center; color: {color};'>{mood}</h2>",
unsafe_allow_html=True)
# Grade display
st.markdown(f"<h3 style='text-align: center;'>Grade: {grade}%</h3>",
unsafe_allow_html=True)
# Mood message
st.markdown(f"<p style='text-align: center; font-style: italic; font-size: 18px;'>'{message}'</p>",
unsafe_allow_html=True)
# Add some fun statistics
st.markdown("---")
st.subheader("πŸ“Š Mood Statistics")
col1, col2, col3 = st.columns(3)
with col1:
st.metric("Happiness Level", f"{min(grade, 100)}%")
with col2:
stress_level = max(0, 100 - grade)
st.metric("Stress Level", f"{stress_level}%")
with col3:
coffee_needed = max(0, (100 - grade) // 10)
st.metric("Coffees Needed", f"{coffee_needed} β˜•")
# Motivational section
st.markdown("---")
if grade < 70:
st.warning("🎯 **Study Tip**: Remember, every expert was once a beginner. You've got this!")
elif grade < 85:
st.info("πŸ’ͺ **Keep Going**: You're doing well! A little more effort can make a big difference.")
else:
st.success("🌟 **Amazing Work**: You're crushing it! Keep up the excellent work!")
# Fun footer
st.markdown("---")