Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| # App title | |
| st.title("🧮 Basic Calculator App") | |
| # Input numbers | |
| st.header("Enter numbers:") | |
| num1 = st.number_input("Enter first number", step=1.0, format="%.2f") | |
| num2 = st.number_input("Enter second number", step=1.0, format="%.2f") | |
| # Select operation | |
| operation = st.selectbox( | |
| "Select Operation", | |
| ("Addition", "Subtraction", "Multiplication", "Division") | |
| ) | |
| # Calculate result | |
| if st.button("Calculate"): | |
| if operation == "Addition": | |
| result = num1 + num2 | |
| st.success(f"Result: {result}") | |
| elif operation == "Subtraction": | |
| result = num1 - num2 | |
| st.success(f"Result: {result}") | |
| elif operation == "Multiplication": | |
| result = num1 * num2 | |
| st.success(f"Result: {result}") | |
| elif operation == "Division": | |
| if num2 != 0: | |
| result = num1 / num2 | |
| st.success(f"Result: {result}") | |
| else: | |
| st.error("Error: Division by zero is not allowed!") | |