Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,4 @@
|
|
| 1 |
-
# import streamlit as st
|
| 2 |
-
|
| 3 |
-
# def calculate_c(a, b):
|
| 4 |
-
# """Calculates the value of c based on the Pythagorean theorem."""
|
| 5 |
-
# return (a**2 + b**2)**0.5 # Use square root to find c
|
| 6 |
-
|
| 7 |
-
# # Create a title and explanation
|
| 8 |
-
# st.title("Pythagorean Theorem Simulator")
|
| 9 |
-
# st.write("Enter the values of a and b to find the hypotenuse (c) using the formula: a² + b² = c²")
|
| 10 |
-
|
| 11 |
-
# # Create input fields for a and b
|
| 12 |
-
# a = st.number_input("Enter value of a:", min_value=0.0)
|
| 13 |
-
# b = st.number_input("Enter value of b:", min_value=0.0)
|
| 14 |
-
|
| 15 |
-
# # Calculate c using the function
|
| 16 |
-
# try:
|
| 17 |
-
# c = calculate_c(a, b)
|
| 18 |
-
# st.write("The value of c is:", c)
|
| 19 |
-
# except ValueError:
|
| 20 |
-
# st.error("Please enter non-negative values for a and b.")
|
| 21 |
-
|
| 22 |
-
# # Display the formula for reference
|
| 23 |
-
# st.write("Formula: a² + b² = c²")
|
| 24 |
-
|
| 25 |
-
# # Add a button for recalculating and information about right triangles
|
| 26 |
-
# st.button("Recalculate") # Button to trigger the calculation again
|
| 27 |
-
# st.markdown("**Note:** This application only works for right triangles. In a right triangle, one angle is exactly 90 degrees.")
|
| 28 |
-
|
| 29 |
-
|
| 30 |
import streamlit as st
|
| 31 |
-
import plotly.express as px
|
| 32 |
|
| 33 |
def calculate_c(a, b):
|
| 34 |
"""Calculates the value of c based on the Pythagorean theorem."""
|
|
@@ -53,18 +23,5 @@ except ValueError:
|
|
| 53 |
st.write("Formula: a² + b² = c²")
|
| 54 |
|
| 55 |
# Add a button for recalculating and information about right triangles
|
| 56 |
-
st.button("Recalculate")
|
| 57 |
-
|
| 58 |
-
# Create the triangle visualization
|
| 59 |
-
if a > 0 and b > 0: # Only create the plot if both sides are positive
|
| 60 |
-
fig = px.scatter(x=[0, a, a, 0], y=[0, 0, b, b],
|
| 61 |
-
labels={"x": "", "y": ""}, title="Right Triangle Visualization")
|
| 62 |
-
fig.update_traces(line_color="blue", line_width=3)
|
| 63 |
-
fig.update_layout(
|
| 64 |
-
xaxis_range=(-1 * max(a, b), max(a, b) + 1),
|
| 65 |
-
yaxis_range=(-1 * max(a, b), max(a, b) + 1),
|
| 66 |
-
showlegend=False
|
| 67 |
-
)
|
| 68 |
-
st.plotly_chart(fig)
|
| 69 |
-
|
| 70 |
-
st.markdown("**Note:** This application only works for right triangles. In a right triangle, one angle is exactly 90 degrees.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
def calculate_c(a, b):
|
| 4 |
"""Calculates the value of c based on the Pythagorean theorem."""
|
|
|
|
| 23 |
st.write("Formula: a² + b² = c²")
|
| 24 |
|
| 25 |
# Add a button for recalculating and information about right triangles
|
| 26 |
+
st.button("Recalculate") # Button to trigger the calculation again
|
| 27 |
+
st.markdown("**Note:** This application only works for right triangles. In a right triangle, one angle is exactly 90 degrees.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|