import streamlit as st
import math
# Set page config
st.set_page_config(page_title="Advanced Calculator", page_icon="🧮", layout="centered")
# Custom CSS for better UI
st.markdown("""
""", unsafe_allow_html=True)
# Main Container
with st.container():
st.markdown("
🧮 Advanced Calculator
", unsafe_allow_html=True)
num1 = st.number_input("Enter first number", value=0.0)
num2 = st.number_input("Enter second number", value=0.0)
operation = st.selectbox(
"Select operation",
["Addition (+)", "Subtraction (-)", "Multiplication (×)", "Division (÷)",
"Modulus (%)", "Exponent (xʸ)", "Square Root (√ First Number)"]
)
if st.button("Calculate"):
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"
elif operation == "Modulus (%)":
result = num1 % num2 if num2 != 0 else "Error: Division by zero"
elif operation == "Exponent (xʸ)":
result = num1 ** num2
elif operation == "Square Root (√ First Number)":
result = math.sqrt(num1) if num1 >= 0 else "Error: Negative number"
st.markdown(f"Result: {result}
", unsafe_allow_html=True)