File size: 645 Bytes
846d3a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)