File size: 1,268 Bytes
c0e523d
 
9910b76
 
 
c0e523d
8ae4718
 
c0e523d
8ae4718
 
 
c0e523d
 
9910b76
 
8ae4718
9910b76
c0e523d
8ae4718
 
 
c0e523d
9910b76
8ae4718
 
 
9910b76
8ae4718
 
9910b76
8ae4718
 
 
 
9910b76
8ae4718
 
 
 
 
c0e523d
8ae4718
 
 
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
import streamlit as st

st.set_page_config(page_title="Three-Field Calculator", layout="centered")

st.title("🧮 Three-Field Calculator")

st.write("Enter three numbers and choose an operation.")

# Input fields
num1 = st.number_input("Enter first number", value=0.0, step=1.0)
num2 = st.number_input("Enter second number", value=0.0, step=1.0)
num3 = st.number_input("Enter third number", value=0.0, step=1.0)

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

# Calculate button
calculate = st.button("Calculate")

result = None

if calculate:
    if operation == "Addition":
        result = num1 + num2 + num3

    elif operation == "Subtraction":
        result = num1 - num2 - num3

    elif operation == "Multiplication":
        result = num1 * num2 * num3
        if num2 == 0 or num3 == 0:
            st.info("Multiplying by zero results in zero.")

    elif operation == "Division":
        if num2 == 0 or num3 == 0:
            st.error("Cannot divide by zero. Please enter non-zero values for second and third numbers.")
        else:
            result = num1 / num2 / num3

    # Display result
    if result is not None:
        st.success(f"Result: {result}")