ZeroTech commited on
Commit
345e1a5
·
1 Parent(s): 1092885

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def calculator(num1, num2, operation):
4
+ if operation == "+":
5
+ return num1 + num2
6
+ elif operation == "-":
7
+ return num1 - num2
8
+ elif operation == "*":
9
+ return num1 * num2
10
+ elif operation == "/":
11
+ if num2 != 0:
12
+ return num1 / num2
13
+ else:
14
+ return "Error: Division by zero"
15
+
16
+ iface = gr.Interface(fn=calculator,
17
+ inputs=[gr.inputs.Number(default=0, label="Num1"),
18
+ gr.inputs.Number(default=0, label="Num2"),
19
+ gr.inputs.Radio(["+", "-", "*", "/"], label="Operation")],
20
+ outputs=gr.outputs.Textbox(type="auto", label="Result"),
21
+ title="Calculator with Buttons",
22
+ theme="compact")
23
+
24
+ iface.launch()