saifch1098 commited on
Commit
7af7ea3
·
verified ·
1 Parent(s): 2dc9418

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Title
4
+ st.title("🧮 Simple Calculator")
5
+
6
+ # User Inputs
7
+ st.write("Enter two numbers and choose an operation:")
8
+ num1 = st.number_input("Enter first number", format="%f")
9
+ num2 = st.number_input("Enter second number", format="%f")
10
+
11
+ operation = st.selectbox("Choose operation", ("Add", "Subtract", "Multiply", "Divide"))
12
+
13
+ # Button
14
+ if st.button("Calculate"):
15
+ if operation == "Add":
16
+ result = num1 + num2
17
+ st.success(f"Result: {result}")
18
+ elif operation == "Subtract":
19
+ result = num1 - num2
20
+ st.success(f"Result: {result}")
21
+ elif operation == "Multiply":
22
+ result = num1 * num2
23
+ st.success(f"Result: {result}")
24
+ elif operation == "Divide":
25
+ if num2 != 0:
26
+ result = num1 / num2
27
+ st.success(f"Result: {result}")
28
+ else:
29
+ st.error("Division by zero is not allowed.")