Mavhas commited on
Commit
c27be71
·
verified ·
1 Parent(s): 9774490

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+
4
+ st.title("Simple Calculator")
5
+
6
+ # Input fields for numbers
7
+ num1 = st.number_input("Enter first number")
8
+ num2 = st.number_input("Enter second number")
9
+
10
+ # Operation selection
11
+ operation = st.selectbox("Select operation", ["+", "-", "*", "/"])
12
+
13
+ # Calculation and display
14
+ if st.button("Calculate"):
15
+ if operation == "+":
16
+ result = num1 + num2
17
+ elif operation == "-":
18
+ result = num1 - num2
19
+ elif operation == "*":
20
+ result = num1 * num2
21
+ elif operation == "/":
22
+ if num2 == 0:
23
+ st.error("Division by zero is not allowed.")
24
+ st.stop() # Stop execution if division by zero
25
+ else:
26
+ result = num1 / num2
27
+ st.write(f"Result: {result}")