File size: 1,586 Bytes
d0e9de5
 
72906a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import streamlit as st

st.title("Simple Calculator")
st.write("This calculator performs basic arithmetic operations.")

# Input fields for the numbers
num1 = st.number_input("Enter 1st number:", value=0.0)
num2 = st.number_input("Enter 2nd number:", value=0.0)

# Operation selection
operation = st.selectbox(
    "Select operation:",("Addition", "Substraction", "Multiplication", "Division", "Exponentiation")
)

# Calculate button
if st.button("Calculate"):
    if operation == "Addition":
        result = num1 + num2
        st.success(f"{num1} - {num2} = {result}")

    elif operation == "Substraction":
        result = num1 - num2
        st.success(f"{num1} - {num2} = {result}")
    
    elif operation == "Multiplication":
        result = num1 * num2
        st.success(f"{num1} * {num2} = {result}")

    elif operation == "Division":
        if num2 == 0:
            st.error("Error: Division by zero!")
        else:
            result = num1 / num2
            st.success(f"{num1} / {num2} = {result}")

    elif operation == "Exponentiation":
        result = num1 ** num2
        st.success(f"{num1} ^ {num2} = {result}")

# Add a divider and display instructions
st.divider()

# Additional calculator history section
st.subheader("History")
st.write("Your calculation history will appear here.")

# How to use section
st.subheader("How to Use")
st.write("""
1. Enter the 1st Number
2. Enter the 2nd Number
3. Select the operation from the dropdown
4. Click the 'Calculate' button
""")

# Footer
st.divider()
st.caption("Simple Calculator App built with Streamlit")