CodeNine commited on
Commit
49c11c3
·
verified ·
1 Parent(s): 73bcfc2

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
+ st.set_page_config(page_title="Simple Calculator", layout="centered")
4
+
5
+ st.title("🧮 Simple Calculator")
6
+
7
+ # Inputs
8
+ num1 = st.number_input("Enter first number", format="%.2f")
9
+ num2 = st.number_input("Enter second number", format="%.2f")
10
+
11
+ operation = st.selectbox("Choose operation", ["Add", "Subtract", "Multiply", "Divide"])
12
+
13
+ # Perform Calculation
14
+ if st.button("Calculate"):
15
+ if operation == "Add":
16
+ result = num1 + num2
17
+ st.success(f"Result: {num1} + {num2} = {result}")
18
+ elif operation == "Subtract":
19
+ result = num1 - num2
20
+ st.success(f"Result: {num1} - {num2} = {result}")
21
+ elif operation == "Multiply":
22
+ result = num1 * num2
23
+ st.success(f"Result: {num1} × {num2} = {result}")
24
+ elif operation == "Divide":
25
+ if num2 != 0:
26
+ result = num1 / num2
27
+ st.success(f"Result: {num1} ÷ {num2} = {result}")
28
+ else:
29
+ st.error("Error: Division by zero is not allowed.")