Mrhuman1's picture
Create app.py
4b22589 verified
Raw
History Blame Contribute Delete
1.08 kB
import streamlit as st
def main():
st.title("Simple Calculator")
st.write("Perform basic arithmetic operations.")
# Input fields
num1 = st.number_input("Enter the first number:", value=0.0)
num2 = st.number_input("Enter the second number:", value=0.0)
operation = st.selectbox("Select an operation:", ["Addition", "Subtraction", "Multiplication", "Division"])
# Perform calculation
if operation == "Addition":
result = num1 + num2
st.success(f"The result of {num1} + {num2} is {result}.")
elif operation == "Subtraction":
result = num1 - num2
st.success(f"The result of {num1} - {num2} is {result}.")
elif operation == "Multiplication":
result = num1 * num2
st.success(f"The result of {num1} * {num2} is {result}.")
elif operation == "Division":
if num2 != 0:
result = num1 / num2
st.success(f"The result of {num1} / {num2} is {result}.")
else:
st.error("Division by zero is not allowed.")
if __name__ == "__main__":
main()