Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| st.set_page_config(page_title="Simple Calculator", layout="centered") | |
| st.title("🧮 Simple Calculator") | |
| # Input fields | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| num1 = st.number_input("First Number", value=0.0) | |
| with col2: | |
| num2 = st.number_input("Second Number", value=0.0) | |
| # Operation selection | |
| operation = st.selectbox("Operation", ["Addition", "Subtraction", "Multiplication", "Division"]) | |
| # Calculate button | |
| if st.button("Calculate"): | |
| try: | |
| if operation == "Addition": | |
| result = num1 + num2 | |
| elif operation == "Subtraction": | |
| result = num1 - num2 | |
| elif operation == "Multiplication": | |
| result = num1 * num2 | |
| elif operation == "Division": | |
| result = num1 / num2 if num2 != 0 else "Error: Division by zero!" | |
| st.success(f"Result: **{result}**") | |
| except Exception as e: | |
| st.error(f"Error: {str(e)}") | |
| # Optional footer | |
| st.markdown("---") | |
| st.caption("Made with Streamlit 🎈 • Hosted on Hugging Face Spaces 🤗") |