Spaces:
Runtime error
Runtime error
import streamlit as st | |
import plotly.graph_objects as go | |
# Set default values | |
x = 5 | |
y = 3 | |
# Create UI elements | |
st.title('Multiply Two Numbers and Add a Constant') | |
x = st.slider('x', min_value=0, max_value=20, value=x) | |
y = st.slider('y', min_value=0, max_value=20, value=y) | |
# Calculate and show the result | |
result = x * y + 13 | |
st.write('Result: ', result) | |
# Create the Plotly chart | |
fig = go.Figure() | |
fig.add_trace(go.Scatter(x=[x], y=[result], mode='markers', name='Result')) | |
# Add equation line | |
x_eq = [0, x] | |
y_eq = [13, result] | |
fig.add_trace(go.Scatter(x=x_eq, y=y_eq, mode='lines', name='Equation')) | |
# Show the chart | |
st.plotly_chart(fig) |