Shahabmoin commited on
Commit
ea48bb6
·
verified ·
1 Parent(s): 5277352

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
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", key="expression_input")
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)', key='sin_button'):
24
- expression += 'sin()'
25
  with col2:
26
- if st.button('cos(x)', key='cos_button'):
27
- expression += 'cos()'
28
  with col3:
29
- if st.button('tan(x)', key='tan_button'):
30
- expression += 'tan()'
31
 
32
  col4, col5, col6 = st.columns(3)
33
 
34
  with col4:
35
- if st.button('log(x)', key='log_button'):
36
- expression += 'log()'
37
  with col5:
38
- if st.button('sqrt(x)', key='sqrt_button'):
39
- expression += 'sqrt()'
40
  with col6:
41
- if st.button('exp(x)', key='exp_button'):
42
- expression += 'exp()'
43
 
44
  col7, col8 = st.columns(2)
45
 
46
  with col7:
47
- if st.button('pi', key='pi_button'):
48
  expression += 'math.pi'
49
  with col8:
50
- if st.button('e', key='e_button'):
51
  expression += 'math.e'
52
 
53
  # Display the updated expression in the text box
54
- expression = st.text_input("Enter a mathematical expression", value=expression, key="expression_input_updated")
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: