Ottosen commited on
Commit
52b824d
·
1 Parent(s): 170ff0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -14
app.py CHANGED
@@ -1,22 +1,32 @@
1
  import gradio as gr
2
 
3
- portion_down_payment = 0.25
4
- current_savings = 0
5
- r = 0.05
6
- monthly_r = r / 12
7
- monthly_salary = annual_salary / 12
8
- months = 0
 
 
 
9
 
10
- def greet(months):
11
- while current_savings <= total_cost * portion_down_payment:
12
- current_savings = current_savings * (1 + monthly_r) + monthly_salary * portion_saved
13
- months += 1
14
- return "Number of months " + str(months) + "!"
15
 
16
  demo = gr.Interface(
17
- fn=greet,
18
- inputs=gr.Textbox(lines=4, placeholder="Name Here...", label="Your name"),
19
- outputs="text",
 
 
 
 
 
 
 
 
 
 
 
 
20
  )
21
 
22
  demo.launch()
 
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
+ return num1 / num2
12
 
 
 
 
 
 
13
 
14
  demo = gr.Interface(
15
+ fn=calculator,
16
+ inputs=[
17
+ gr.Number(value=4),
18
+ gr.Radio(["add", "subtract", "multiply", "divide"]),
19
+ "number"
20
+ ],
21
+ outputs="number",
22
+ examples=[
23
+ [5, "add", 3],
24
+ [4, "divide", 2],
25
+ [-4, "multiply", 2.5],
26
+ [0, "subtract", 1.2],
27
+ ],
28
+ title="test calculator",
29
+ description="heres a sample **toy calculator**. enjoy!",
30
  )
31
 
32
  demo.launch()