Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.title("Simple Calculator")
|
| 4 |
+
a, b, c, d = st.columns(4)
|
| 5 |
+
|
| 6 |
+
def calculator():
|
| 7 |
+
num1 = st.number_input("Input First Number Here")
|
| 8 |
+
num2 = st.number_input("Input Second Number Here")
|
| 9 |
+
if a.button("Addition"):
|
| 10 |
+
add = num1 + num2
|
| 11 |
+
st.write(f"The Result Is: {add}")
|
| 12 |
+
if b.button("Multiplication"):
|
| 13 |
+
mul = num1 * num2
|
| 14 |
+
st.write(f"The Result Is: {mul}")
|
| 15 |
+
if c.button("Division"):
|
| 16 |
+
if num2 != 0:
|
| 17 |
+
div = num1 / num2
|
| 18 |
+
st.write(f"The Result Is: {div}")
|
| 19 |
+
else:
|
| 20 |
+
st.error("Division by Zero is not allowed.")
|
| 21 |
+
if d.button("Minus"):
|
| 22 |
+
sub = num1 - num2
|
| 23 |
+
st.write(f"The Result Is: {sub}")
|
| 24 |
+
|
| 25 |
+
calculator()
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
#(
|
| 31 |
+
#debar.title("Calculator App")
|
| 32 |
+
#e = st.sidebar.radio("Select Operation", ("Addition",))
|
| 33 |
+
#
|
| 34 |
+
# page == "Addition":
|
| 35 |
+
# add()
|
| 36 |
+
#name__ == "__main__":
|
| 37 |
+
|
| 38 |
+
|