BetaGen commited on
Commit
c4da749
·
verified ·
1 Parent(s): 83ac8a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(page_title="Simple Calculator", layout="centered")
4
+
5
+ st.title("🧮 Simple Calculator")
6
+
7
+ # Input numbers
8
+ num1 = st.number_input("Enter first number", format="%f")
9
+ num2 = st.number_input("Enter second number", format="%f")
10
+
11
+ # Operation selection
12
+ operation = st.selectbox("Select operation", ["Add", "Subtract", "Multiply", "Divide"])
13
+
14
+ # Perform calculation
15
+ result = None
16
+ if st.button("Calculate"):
17
+ if operation == "Add":
18
+ result = num1 + num2
19
+ elif operation == "Subtract":
20
+ result = num1 - num2
21
+ elif operation == "Multiply":
22
+ result = num1 * num2
23
+ elif operation == "Divide":
24
+ if num2 != 0:
25
+ result = num1 / num2
26
+ else:
27
+ st.error("Division by zero is not allowed.")
28
+
29
+ # Show result
30
+ if result is not None:
31
+ st.success(f"Result: {result}")