import streamlit as st import math # Title of the web app st.title("✨ Enhanced Calculator ✨") # Dropdown menu for operation selection with emojis operation = st.selectbox( "Select an operation:", ["➕ Addition", "➖ Subtraction", "✖️ Multiplication", "➗ Division", "🔢 Exponentiation", "🌟 Square Root"] ) # Number inputs based on the selected operation if operation in ["➕ Addition", "➖ Subtraction", "✖️ Multiplication", "➗ Division", "🔢 Exponentiation"]: num1 = st.number_input("Enter the first number: 🏷️", value=0.0) num2 = st.number_input("Enter the second number: 🏷️", value=0.0) 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!") elif operation == "🔢 Exponentiation": result = math.pow(num1, num2) st.success(f"✅ Result: {result}") elif operation == "🌟 Square Root": num = st.number_input("Enter the number: 🏷️", value=0.0) if st.button("📊 Calculate"): if num >= 0: result = math.sqrt(num) st.success(f"✅ Result: {result}") else: st.error("🚫 Error: Cannot calculate the square root of a negative number!")