-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguistcalc.py
More file actions
26 lines (21 loc) · 730 Bytes
/
guistcalc.py
File metadata and controls
26 lines (21 loc) · 730 Bytes
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
import streamlit as st
def simple_calculator():
st.title("simple calculator")
num1=st.number_input("enter the first number ",format='%g')
operation=st.selectbox("choose an operation ",["Addition","Subtraction","Multiplication","Division"])
num2=st.number_input("enter the second number ",format='%g')
result=0.0
if operation=="Addition":
result=num1+num2
elif operation=="Subtraction":
result=num1-num2
elif operation=="Multiplication":
result=num1*num2
else:
if num2!=0:
result=num1/num2
else:
st.error("zero division error")
st.write(f"results={result}")
if __name__=="__main__":
simple_calculator()