AZhr92/Calculator-1_stmlit
0
1import streamlit as st2 3st.title("🧮 Simple Calculator")4st.write("Enter two numbers and select an operation to perform.")5 6# Input fields7num1 = st.number_input("Enter the first number", format="%.2f")8num2 = st.number_input("Enter the second number", format="%.2f")9operation = st.radio("Select operation", ("Add", "Subtract", "Multiply", "Divide"))10 11# Perform calculation12if st.button("Calculate"):13 try:14 if operation == "Add":15 result = num1 + num216 st.success(f"{num1} + {num2} = {result}")17 elif operation == "Subtract":18 result = num1 - num219 st.success(f"{num1} - {num2} = {result}")20 elif operation == "Multiply":21 result = num1 * num222 st.success(f"{num1} * {num2} = {result}")23 elif operation == "Divide":24 if num2 == 0:25 st.error("Error: Division by zero is not allowed.")26 else:27 result = num1 / num228 st.success(f"{num1} / {num2} = {result}")29 except Exception as e:30 st.error(f"An error occurred: {e}")31 