Spaces:
Build error
Build error
Delete Operator.py
Browse files- Operator.py +0 -35
Operator.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
|
| 3 |
-
def calculator(num1, operation, num2):
|
| 4 |
-
if operation == "add":
|
| 5 |
-
return num1 + num2
|
| 6 |
-
elif operation == "subtract":
|
| 7 |
-
return num1 - num2
|
| 8 |
-
elif operation == "multiply":
|
| 9 |
-
return num1 * num2
|
| 10 |
-
elif operation == "divide":
|
| 11 |
-
if num2 == 0:
|
| 12 |
-
raise gr.Error("Cannot divide by zero!")
|
| 13 |
-
return num1 / num2
|
| 14 |
-
elif operation == "power":
|
| 15 |
-
return num1 ** num2
|
| 16 |
-
|
| 17 |
-
demo = gr.Interface(
|
| 18 |
-
calculator,
|
| 19 |
-
[
|
| 20 |
-
"number",
|
| 21 |
-
gr.Radio(["add", "subtract", "multiply", "divide","power"]),
|
| 22 |
-
"number"
|
| 23 |
-
],
|
| 24 |
-
"number",
|
| 25 |
-
examples=[
|
| 26 |
-
[5, "add", 3],
|
| 27 |
-
[4, "divide", 2],
|
| 28 |
-
[-4, "multiply", 2.5],
|
| 29 |
-
[0, "subtract", 1.2],
|
| 30 |
-
[3, "power", 2],
|
| 31 |
-
],
|
| 32 |
-
title="Toy Calculator",
|
| 33 |
-
description="Here's a sample toy calculator. Enjoy!",
|
| 34 |
-
)
|
| 35 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|