Spaces:
Sleeping
Sleeping
# prompt: Using Gradio to write a simple calculator app | |
import gradio | |
def calculator(num1, operation, num2): | |
if operation == "add": | |
return num1 + num2 | |
elif operation == "subtract": | |
return num1 - num2 | |
elif operation == "multiply": | |
return num1 * num2 | |
elif operation == "divide": | |
return num1 / num2 | |
demo = gradio.Interface( | |
fn=calculator, | |
inputs=["number", gradio.Radio(["add", "subtract", "multiply", "divide"]), "number"], | |
outputs="number") | |
demo.launch() | |