We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 935cf77 commit f240f99Copy full SHA for f240f99
calculator.py
@@ -0,0 +1,44 @@
1
+import math
2
+n1=int(input("Enter 1st number :"))
3
+n2=int(input("Enter 2nd number :"))
4
+c=input("Enter operation to be performed :")
5
+def add(a,b):
6
+ return (a+b)
7
+def sub(a,b):
8
+ return (a-b)
9
+def mul(a,b):
10
+ return (a*b)
11
+def div(a,b):
12
+ return (a/b)
13
+def exp(a,b):
14
+ return (a**b)
15
+def log(a):
16
+ return math.log(a)
17
+if(c=="add"):
18
+ r=add(n1,n2)
19
+ print(r)
20
+elif(c=="sub"):
21
+ r=sub(n1,n2)
22
23
+elif(c=="mul"):
24
+ r=mul(n1,n2)
25
26
+elif(c=="div"):
27
+ r=div(n1,n2)
28
29
+elif(c=="log"):
30
+ n=(int)(input("log of 1 or 2?"))
31
+ if(n==1):
32
+ r=log(n1)
33
34
+ elif(n==2):
35
+ r=log(n2)
36
37
+elif(c=="exp"):
38
+ r=exp(n1,n2)
39
40
+
41
42
43
44
0 commit comments