calculator9dec / app.py
decodingdatascience's picture
Create app.py
0e54c10
raw
history blame contribute delete
551 Bytes
import gradio as gr
def calculator(operator, num1, num2):
if operator == "+":
result = num1 + num2
elif operator == "-":
result = num1 - num2
elif operator == "*":
result = num1 * num2
elif operator == "/":
if num2 != 0:
result = num1/num2
else:
return "Error, Division by zero not allowed"
else:
return f"Error, {operator} is invalid. Please try again "
return result
iface = gr.Interface( fn=calculator,
inputs=["text","number","number"],
outputs="text")
iface.launch(share=True)