Bushra346 commited on
Commit
f31d70b
·
verified ·
1 Parent(s): 5c31c19

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import streamlit as st
4
+
5
+ st.set_page_config(page_title="Simple Calculator", page_icon="🧮")
6
+
7
+ st.title("🧮 Simple Calculator")
8
+ st.write("This calculator can do addition (+), subtraction (-), multiplication (*), and division (/).")
9
+
10
+ # Get user input
11
+ expression = st.text_input("Enter a math expression (e.g., 5 + 3):")
12
+
13
+ def calculate(expr):
14
+ try:
15
+ # Safely evaluate the expression
16
+ result = eval(expr)
17
+ return result
18
+ except:
19
+ return "Invalid input"
20
+
21
+ if st.button("Calculate"):
22
+ result = calculate(expression)
23
+ st.write(f"Result: **{result}**")