forked from GregHilston/github-tutorial-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.py
60 lines (39 loc) · 1.14 KB
/
calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import math
class Calculator:
"""A simple Calculator class used to demonstrate Git and Github features
"""
def add(self, x, y):
"""Adds x and y together and returns the sum
"""
return x + y
def subtract(self, x, y):
"""Subtracts y from x and returns the difference
"""
return x - y
def multiply(self, x, y):
"""Multiples x by y and returns the product
"""
return (x * y)
def divide(self, x, y):
"""Divides x by y and returns the quotient.
Note, that this uses Integer division.
"""
return x//y
def tan(self, x):
"""Returns the tangent value of x
"""
return math.tan(x)
def log(self, x, y):
return math.log(x,y)
def square(self, x):
""" Returns the square of x.
"""
return (x * x)
def cube(self, x):
"""Returns the cubed value of x.
"""
return (x * x * x)
def sin(self, x):
""" Returns the sin value of x.
"""
return math.sin(x)