import streamlit as st def calculate_c(a, b): """Calculates the value of c based on the Pythagorean theorem.""" return (a**2 + b**2)**0.5 # Use square root to find c # Create a title and explanation st.title("Pythagorean Theorem Simulator") st.write("Enter the values of a and b to find the hypotenuse (c) using the formula: a² + b² = c²") # Create input fields for a and b a = st.number_input("Enter value of a:", min_value=0) b = st.number_input("Enter value of b:", min_value=0) # Calculate c using the function try: c = calculate_c(a, b) st.write("The value of c is:", c,font="large") except ValueError: st.error("Please enter non-negative values for a and b.") # Display the formula for reference st.write("Formula: a² + b² = c²") # Add a button for recalculating and information about right triangles st.button("Recalculate") # Button to trigger the calculation again st.markdown("**Note:** This application only works for right triangles. In a right triangle, one angle is exactly 90 degrees.")