File size: 1,438 Bytes
2d82a2e
 
 
5480678
2d82a2e
 
 
 
5480678
2d82a2e
 
09e7a8a
2d82a2e
 
 
5480678
2d82a2e
5480678
2d82a2e
5480678
2d82a2e
5480678
 
2d82a2e
 
5480678
 
09e7a8a
 
 
 
5480678
 
 
 
 
2d82a2e
 
 
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
import streamlit as st

# Set the title of the app
st.title('Extended Calculator')

# Get user inputs for the calculation
num1 = st.number_input('Enter first number', value=0)
num2 = st.number_input('Enter second number', value=0)
num3 = st.number_input('Enter third number', value=0)

# Create options for selecting the type of operation
operation = st.selectbox('Choose operation', ('Add', 'Subtract', 'Multiply', 'Divide', 'Average', 'Exponentiation', 'Modulus'))

# Perform calculation based on the selected operation
if operation == 'Add':
    result = num1 + num2 + num3
elif operation == 'Subtract':
    result = num1 - num2 - num3
elif operation == 'Multiply':
    result = num1 * num2 * num3
elif operation == 'Divide':
    if num2 != 0 and num3 != 0:
        result = num1 / num2 / num3
    else:
        result = 'Error! Division by Zero'
elif operation == 'Average':
    result = (num1 + num2 + num3) / 3
elif operation == 'Exponentiation':
    base = st.number_input('Enter the base number', value=1)  # Get base input from the user
    exponent = st.number_input('Enter the exponent number', value=1)  # Get exponent input from the user
    result = base ** exponent  # Exponentiation calculation
elif operation == 'Modulus':
    if num2 != 0 and num3 != 0:
        result = num1 % num2 % num3
    else:
        result = 'Error! Modulus by Zero'

# Display the result of the calculation
st.write(f'The result is: {result}')