SHAILJA1 commited on
Commit
1e040d3
·
verified ·
1 Parent(s): 64f0160

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -1 +1,26 @@
1
- print("hi")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def calculator(a, b, operation):
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
+ with gr.Blocks() as demo:
14
+ gr.Markdown("# 🧮 Simple Calculator")
15
+
16
+ with gr.Row():
17
+ a = gr.Number(label="First Number")
18
+ b = gr.Number(label="Second Number")
19
+
20
+ operation = gr.Radio(["Add", "Subtract", "Multiply", "Divide"], label="Operation")
21
+ result = gr.Textbox(label="Result")
22
+
23
+ btn = gr.Button("Calculate")
24
+ btn.click(calculator, inputs=[a, b, operation], outputs=result)
25
+
26
+ demo.launch()