Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,44 +14,44 @@ def calculate(expression):
|
|
14 |
st.title("Scientific Calculator")
|
15 |
|
16 |
# Input for the mathematical expression
|
17 |
-
expression = st.text_input("Enter a mathematical expression",
|
18 |
|
19 |
# Create buttons below the input field for mathematical operations
|
20 |
col1, col2, col3 = st.columns(3)
|
21 |
|
22 |
with col1:
|
23 |
-
if st.button('sin(x)'
|
24 |
-
expression += 'sin(
|
25 |
with col2:
|
26 |
-
if st.button('cos(x)'
|
27 |
-
expression += 'cos(
|
28 |
with col3:
|
29 |
-
if st.button('tan(x)'
|
30 |
-
expression += 'tan(
|
31 |
|
32 |
col4, col5, col6 = st.columns(3)
|
33 |
|
34 |
with col4:
|
35 |
-
if st.button('log(x)'
|
36 |
-
expression += 'log(
|
37 |
with col5:
|
38 |
-
if st.button('sqrt(x)'
|
39 |
-
expression += 'sqrt(
|
40 |
with col6:
|
41 |
-
if st.button('exp(x)'
|
42 |
-
expression += 'exp(
|
43 |
|
44 |
col7, col8 = st.columns(2)
|
45 |
|
46 |
with col7:
|
47 |
-
if st.button('pi'
|
48 |
expression += 'math.pi'
|
49 |
with col8:
|
50 |
-
if st.button('e'
|
51 |
expression += 'math.e'
|
52 |
|
53 |
# Display the updated expression in the text box
|
54 |
-
|
55 |
|
56 |
# Operations
|
57 |
if expression:
|
|
|
14 |
st.title("Scientific Calculator")
|
15 |
|
16 |
# Input for the mathematical expression
|
17 |
+
expression = st.text_input("Enter a mathematical expression", "")
|
18 |
|
19 |
# Create buttons below the input field for mathematical operations
|
20 |
col1, col2, col3 = st.columns(3)
|
21 |
|
22 |
with col1:
|
23 |
+
if st.button('sin(x)'):
|
24 |
+
expression += 'sin('
|
25 |
with col2:
|
26 |
+
if st.button('cos(x)'):
|
27 |
+
expression += 'cos('
|
28 |
with col3:
|
29 |
+
if st.button('tan(x)'):
|
30 |
+
expression += 'tan('
|
31 |
|
32 |
col4, col5, col6 = st.columns(3)
|
33 |
|
34 |
with col4:
|
35 |
+
if st.button('log(x)'):
|
36 |
+
expression += 'log('
|
37 |
with col5:
|
38 |
+
if st.button('sqrt(x)'):
|
39 |
+
expression += 'sqrt('
|
40 |
with col6:
|
41 |
+
if st.button('exp(x)'):
|
42 |
+
expression += 'exp('
|
43 |
|
44 |
col7, col8 = st.columns(2)
|
45 |
|
46 |
with col7:
|
47 |
+
if st.button('pi'):
|
48 |
expression += 'math.pi'
|
49 |
with col8:
|
50 |
+
if st.button('e'):
|
51 |
expression += 'math.e'
|
52 |
|
53 |
# Display the updated expression in the text box
|
54 |
+
st.text_input("Enter a mathematical expression", expression)
|
55 |
|
56 |
# Operations
|
57 |
if expression:
|