Emanrashid7 commited on
Commit
e064d74
·
verified ·
1 Parent(s): 11475f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def calculator():
4
+ st.title("Simple Calculator")
5
+
6
+ num1 = st.number_input("Enter first number", value=0.0, format="%.2f")
7
+ num2 = st.number_input("Enter second number", value=0.0, format="%.2f")
8
+
9
+ operation = st.selectbox("Choose an operation", ["Addition", "Subtraction", "Multiplication", "Division"])
10
+
11
+ if st.button("Calculate"):
12
+ if operation == "Addition":
13
+ result = num1 + num2
14
+ elif operation == "Subtraction":
15
+ result = num1 - num2
16
+ elif operation == "Multiplication":
17
+ result = num1 * num2
18
+ elif operation == "Division":
19
+ if num2 != 0:
20
+ result = num1 / num2
21
+ else:
22
+ result = "Error! Division by zero."
23
+
24
+ st.success(f"Result: {result}")
25
+
26
+ if __name__ == "__main__":
27
+ calculator()