Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import plotly.graph_objects as go
|
3 |
+
|
4 |
+
# Set default values
|
5 |
+
x = 5
|
6 |
+
y = 3
|
7 |
+
|
8 |
+
# Create UI elements
|
9 |
+
st.title('Multiply Two Numbers and Add a Constant')
|
10 |
+
x = st.slider('x', min_value=0, max_value=20, value=x)
|
11 |
+
y = st.slider('y', min_value=0, max_value=20, value=y)
|
12 |
+
|
13 |
+
# Calculate and show the result
|
14 |
+
result = x * y + 13
|
15 |
+
st.write('Result: ', result)
|
16 |
+
|
17 |
+
# Create the Plotly chart
|
18 |
+
fig = go.Figure()
|
19 |
+
fig.add_trace(go.Scatter(x=[x], y=[result], mode='markers', name='Result'))
|
20 |
+
|
21 |
+
# Add equation line
|
22 |
+
x_eq = [0, x]
|
23 |
+
y_eq = [13, result]
|
24 |
+
|
25 |
+
fig.add_trace(go.Scatter(x=x_eq, y=y_eq, mode='lines', name='Equation'))
|
26 |
+
|
27 |
+
# Show the chart
|
28 |
+
st.plotly_chart(fig)
|