tbaig1605 commited on
Commit
0c2e410
·
verified ·
1 Parent(s): 74e8c88

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(page_title="Simple Calculator", page_icon="🧮")
4
+
5
+ st.title("🧮 Simple Calculator")
6
+ st.write("This app performs basic arithmetic operations: +, −, ×, ÷")
7
+
8
+ # Input numbers
9
+ num1 = st.number_input("Enter the first number", format="%.2f")
10
+ num2 = st.number_input("Enter the second number", format="%.2f")
11
+
12
+ # Operation selection
13
+ operation = st.selectbox("Choose operation", ("Addition (+)", "Subtraction (−)", "Multiplication (×)", "Division (÷)"))
14
+
15
+ # Calculate result
16
+ if st.button("Calculate"):
17
+ if operation == "Addition (+)":
18
+ result = num1 + num2
19
+ st.success(f"Result: {result}")
20
+ elif operation == "Subtraction (−)":
21
+ result = num1 - num2
22
+ st.success(f"Result: {result}")
23
+ elif operation == "Multiplication (×)":
24
+ result = num1 * num2
25
+ st.success(f"Result: {result}")
26
+ elif operation == "Division (÷)":
27
+ if num2 != 0:
28
+ result = num1 / num2
29
+ st.success(f"Result: {result}")
30
+ else:
31
+ st.error("Error: Division by zero is not allowed.")