lpnguyen commited on
Commit
854eb71
1 Parent(s): 7f1610a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -30
app.py CHANGED
@@ -1,32 +1,22 @@
1
  import streamlit as st
2
- import numpy as np
3
- import pandas as pd
4
- import altair as alt
5
 
6
- st.write('Hello World')
7
-
8
- st.header('button')
9
-
10
- if st.button('Say Hello'):
11
- st.write('Why hello there')
12
- else:
13
- st.write('Goodbye')
14
-
15
-
16
- st.header('st.write')
17
-
18
- st.write('Hello World')
19
- st.write(1234)
20
-
21
- df = pd.DataFrame({'first column':[1, 2, 3, 4], 'second column': [10, 20, 30, 40]})
22
- st.write(df)
23
-
24
- df2 = pd.DataFrame(
25
- np.random.randn(200, 3),
26
- columns=['a', 'b', 'c'])
27
- st.write(df2.head(5))
28
- c = alt.Chart(df2).mark_circle().encode(
29
- x='a', y='b', size='c', color='c', tooltip=['a', 'b', 'c'])
30
- st.write(c)
31
-
32
- st.latex(r'N_t = \frac{1}{10}')
 
1
  import streamlit as st
 
 
 
2
 
3
+ st.title("Calculator")
4
+
5
+ col1, col2, col3 = st.columns(3)
6
+ with col1:
7
+ a = st.number_input("First number", value=1.0)
8
+ with col2:
9
+ b = st.number_input("Second number", value=2.0)
10
+ with col3:
11
+ operation = st.selectbox("Choose the operation", ["+", "-", "*", "/"])
12
+ if operation == "+":
13
+ st.write(a, "+", b, "=", a + b)
14
+ elif operation == "-":
15
+ st.write(a, "-", b, "=", a - b)
16
+ elif operation == "*":
17
+ st.write(a, "*", b, "=", a * b)
18
+ elif operation == "/":
19
+ if b == 0:
20
+ st.warning("Divided by zero")
21
+ else:
22
+ st.write(a, "/", b, "=", a / b)