import streamlit as st # Page config st.set_page_config(page_title="Simple Calculator", page_icon="๐Ÿงฎ", layout="centered") # Title and subtitle st.title("๐Ÿงฎ Simple Streamlit Calculator") st.markdown("Perform basic math operations with ease.") # Divider st.markdown("---") # Input fields col1, col2 = st.columns(2) with col1: num1 = st.number_input("๐Ÿ”ข Enter the first number", format="%.2f") with col2: num2 = st.number_input("๐Ÿ”ข Enter the second number", format="%.2f") # Operation selection operation = st.selectbox("โž• Choose an operation", ["Addition", "Subtraction", "Multiplication", "Division"]) # Button and result if st.button("๐Ÿ’ก Calculate"): st.markdown("### ๐Ÿงพ Result") try: if operation == "Addition": result = num1 + num2 elif operation == "Subtraction": result = num1 - num2 elif operation == "Multiplication": result = num1 * num2 elif operation == "Division": if num2 == 0: st.error("๐Ÿšซ Cannot divide by zero.") result = None else: result = num1 / num2 if result is not None: st.success(f"โœ… The result is: `{result}`") except Exception as e: st.error(f"โŒ An error occurred: {e}") # Footer st.markdown("---") st.caption("Created with โค๏ธ using BilalCode")