Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
def add(x,y):
|
| 4 |
+
return x+y
|
| 5 |
+
|
| 6 |
+
def sub(x,y):
|
| 7 |
+
return x-y
|
| 8 |
+
|
| 9 |
+
def multiply(x,y):
|
| 10 |
+
return x*y
|
| 11 |
+
|
| 12 |
+
def divide(x,y):
|
| 13 |
+
if y==0:
|
| 14 |
+
return "Sorry Not possible"
|
| 15 |
+
else:
|
| 16 |
+
return x/y
|
| 17 |
+
|
| 18 |
+
st.title("SIMPLE CALCULATOR BY FSA")
|
| 19 |
+
|
| 20 |
+
num1 = st.number_input("enter first number: ")
|
| 21 |
+
num2 = st.number_input("enter second number: ")
|
| 22 |
+
|
| 23 |
+
choice = st.radio("Select your choice",("ADD","SUBTRACT","MULTIPLY","DIVIDE"))
|
| 24 |
+
|
| 25 |
+
if choice=="ADD":
|
| 26 |
+
result = add(num1,num2)
|
| 27 |
+
elif choice=="SUBTRACT":
|
| 28 |
+
result = sub(num1,num2)
|
| 29 |
+
elif choice=="MULTIPLY":
|
| 30 |
+
result = multiply(num1,num2)
|
| 31 |
+
elif choice=="DIVIDE":
|
| 32 |
+
result = divide(num1,num2)
|
| 33 |
+
|
| 34 |
+
st.write("Result is: ",result)
|