JaveriaZia commited on
Commit
3441337
·
verified ·
1 Parent(s): 03a873b

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 App")
5
+
6
+ # Input fields
7
+ num1 = st.number_input("Enter first number", format="%.2f")
8
+ num2 = st.number_input("Enter second number", format="%.2f")
9
+
10
+ # Operation selection
11
+ operation = st.selectbox("Select operation", ["Add", "Subtract", "Multiply", "Divide"])
12
+
13
+ # Calculate and display result
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("Cannot divide by zero")