Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def calculator(num1, num2, operation): | |
| if operation == "+": | |
| return num1 + num2 | |
| elif operation == "-": | |
| return num1 - num2 | |
| elif operation == "*": | |
| return num1 * num2 | |
| elif operation == "/": | |
| if num2 != 0: | |
| return num1 / num2 | |
| else: | |
| return "Error: Division by zero" | |
| iface = gr.Interface(fn=calculator, | |
| inputs=[gr.inputs.Number(default=0, label="Num1"), | |
| gr.inputs.Number(default=0, label="Num2"), | |
| gr.inputs.Radio(["+", "-", "*", "/"], label="Operation")], | |
| outputs=gr.outputs.Textbox(type="text", label="Result"), | |
| title="Calculator with Buttons", | |
| theme="compact") | |
| iface.launch() | |