Usually3 commited on
Commit
626683a
·
1 Parent(s): 564b4e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
-
3
 
4
  def calculator(num1, operation, num2):
5
  if operation == "add":
@@ -14,21 +14,15 @@ def calculator(num1, operation, num2):
14
  return num1 * num1
15
  elif operation == "cube":
16
  return num1 * num1 * num1
17
- elif operation == "sin":
18
- return math.sin(num1)
19
- elif operation == "cos":
20
- return math.cos(num1)
21
- elif operation == "tan":
22
- return math.tan(num1)
23
- else:
24
- return None
25
 
26
  demo = gr.Interface(
27
  fn=calculator,
28
  inputs=[
29
  gr.Number(value=4),
30
- gr.Radio(["add", "subtract", "multiply", "divide", "square", "cube", "sin", "cos", "tan"]),
31
- "number"
32
  ],
33
  outputs="number",
34
  examples=[
@@ -36,6 +30,7 @@ demo = gr.Interface(
36
  [4, "divide", 2],
37
  [-4, "multiply", 2.5],
38
  [0, "subtract", 1.2],
 
39
  ],
40
  title="Scientific Calculator",
41
  description="Here's a sample scientific calculator. Enjoy! Code by: Freddy Aboulton Improved by: Usually3"
 
1
  import gradio as gr
2
+ import math
3
 
4
  def calculator(num1, operation, num2):
5
  if operation == "add":
 
14
  return num1 * num1
15
  elif operation == "cube":
16
  return num1 * num1 * num1
17
+ elif operation == "exponential":
18
+ return math.pow(num1, num2)
 
 
 
 
 
 
19
 
20
  demo = gr.Interface(
21
  fn=calculator,
22
  inputs=[
23
  gr.Number(value=4),
24
+ gr.Radio(["add", "subtract", "multiply", "divide", "square", "cube", "exponential"]),
25
+ gr.Number(value=2)
26
  ],
27
  outputs="number",
28
  examples=[
 
30
  [4, "divide", 2],
31
  [-4, "multiply", 2.5],
32
  [0, "subtract", 1.2],
33
+ [2, "exponential", 3]
34
  ],
35
  title="Scientific Calculator",
36
  description="Here's a sample scientific calculator. Enjoy! Code by: Freddy Aboulton Improved by: Usually3"