Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| # App title | |
| st.title("Simple Calculator (+, -)") | |
| # Input numbers | |
| num1 = st.number_input("Enter first number:", format="%.2f") | |
| num2 = st.number_input("Enter second number:", format="%.2f") | |
| # Operation selection | |
| operation = st.radio("Choose operation:", ("Addition (+)", "Subtraction (-)")) | |
| # Perform calculation | |
| if st.button("Calculate"): | |
| if operation == "Addition (+)": | |
| result = num1 + num2 | |
| st.success(f"Result: {num1} + {num2} = {result}") | |
| elif operation == "Subtraction (-)": | |
| result = num1 - num2 | |
| st.success(f"Result: {num1} - {num2} = {result}") | |