CoolFace
Apppublic

awacke1/STEM-MathExercise

sourceHugging Facemitupdated 4y agoView on Hugging Face
1likes
app.py28 linesDownload Raw Back to root
1import streamlit as st2import plotly.graph_objects as go3 4# Set default values5x = 56y = 37 8# Create UI elements9st.title('Multiply Two Numbers and Add a Constant')10x = st.slider('x', min_value=0, max_value=20, value=x)11y = st.slider('y', min_value=0, max_value=20, value=y)12 13# Calculate and show the result14result = x * y + 1315st.write('Result: ', result)16 17# Create the Plotly chart18fig = go.Figure()19fig.add_trace(go.Scatter(x=[x], y=[result], mode='markers', name='Result'))20 21# Add equation line22x_eq = [0, x]23y_eq = [13, result]24 25fig.add_trace(go.Scatter(x=x_eq, y=y_eq, mode='lines', name='Equation'))26 27# Show the chart28st.plotly_chart(fig)