Spaces:
Sleeping
Sleeping
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) | |