Spaces:
Build error
Build error
Commit
·
05282d2
1
Parent(s):
6a407ea
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def calculate(operation, a, b):
|
| 4 |
+
if operation == 'Add':
|
| 5 |
+
return a + b
|
| 6 |
+
elif operation == 'Subtract':
|
| 7 |
+
return a - b
|
| 8 |
+
elif operation == 'Multiply':
|
| 9 |
+
return a * b
|
| 10 |
+
elif operation == 'Divide':
|
| 11 |
+
return a / b if b != 0 else 'Error: Division by zero'
|
| 12 |
+
|
| 13 |
+
interface = gr.Interface(
|
| 14 |
+
fn=calculate,
|
| 15 |
+
inputs=[
|
| 16 |
+
gr.Dropdown(choices=['Add', 'Subtract', 'Multiply', 'Divide'], label="Operation"),
|
| 17 |
+
gr.Number(label="First Number"),
|
| 18 |
+
gr.Number(label="Second Number")
|
| 19 |
+
],
|
| 20 |
+
outputs="text"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
interface.launch()
|
| 25 |
+
|
| 26 |
+
|