Spaces:
Running
Running
Delete app.py with huggingface_hub
Browse files
app.py
DELETED
@@ -1,33 +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 |
-
|
15 |
-
demo = gr.Interface(
|
16 |
-
calculator,
|
17 |
-
[
|
18 |
-
"number",
|
19 |
-
gr.Radio(["add", "subtract", "multiply", "divide"]),
|
20 |
-
"number"
|
21 |
-
],
|
22 |
-
"number",
|
23 |
-
examples=[
|
24 |
-
[5, "add", 3],
|
25 |
-
[4, "divide", 2],
|
26 |
-
[-4, "multiply", 2.5],
|
27 |
-
[0, "subtract", 1.2],
|
28 |
-
],
|
29 |
-
title="Toy Calculator",
|
30 |
-
description="Here's a sample toy calculator. Enjoy!",
|
31 |
-
)
|
32 |
-
if __name__ == "__main__":
|
33 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|