Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| st.set_page_config(page_title="Three-Field Calculator", layout="centered") | |
| st.title("🧮 Three-Field Calculator") | |
| st.write("Enter three numbers and choose an operation.") | |
| # Input fields | |
| num1 = st.number_input("Enter first number", value=0.0, step=1.0) | |
| num2 = st.number_input("Enter second number", value=0.0, step=1.0) | |
| num3 = st.number_input("Enter third number", value=0.0, step=1.0) | |
| # Operation selection | |
| operation = st.selectbox( | |
| "Select operation", | |
| ("Addition", "Subtraction", "Multiplication", "Division") | |
| ) | |
| # Calculate button | |
| calculate = st.button("Calculate") | |
| result = None | |
| if calculate: | |
| if operation == "Addition": | |
| result = num1 + num2 + num3 | |
| elif operation == "Subtraction": | |
| result = num1 - num2 - num3 | |
| elif operation == "Multiplication": | |
| result = num1 * num2 * num3 | |
| if num2 == 0 or num3 == 0: | |
| st.info("Multiplying by zero results in zero.") | |
| elif operation == "Division": | |
| if num2 == 0 or num3 == 0: | |
| st.error("Cannot divide by zero. Please enter non-zero values for second and third numbers.") | |
| else: | |
| result = num1 / num2 / num3 | |
| # Display result | |
| if result is not None: | |
| st.success(f"Result: {result}") | |