import streamlit as st def main(): st.title("Simple Calculator") # Input fields num1 = st.number_input("Enter first number", value=0.0, format="%f") num2 = st.number_input("Enter second number", value=0.0, format="%f") # Operation selection operation = st.selectbox("Choose operation", ["Add", "Subtract", "Multiply", "Divide"]) result = None # Perform calculation if st.button("Calculate"): if operation == "Add": result = num1 + num2 elif operation == "Subtract": result = num1 - num2 elif operation == "Multiply": result = num1 * num2 elif operation == "Divide": if num2 != 0: result = num1 / num2 else: st.error("Division by zero is not allowed") result = "Undefined" st.success(f"Result: {result}") if __name__ == "__main__": main()