-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharithmetic.py
More file actions
49 lines (25 loc) · 854 Bytes
/
arithmetic.py
File metadata and controls
49 lines (25 loc) · 854 Bytes
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
"""Functions for common math operations."""
def add(num1, num2):
"""Return the sum of num1 + num2."""
return num1 + num2
def subtract(num1, num2):
"""Return the value of num1 minus num2."""
return num1 - num2
def multiply(num1, num2):
"""Multiply the num1 by num2 and return the result."""
return num1 * num2
def divide(num1, num2):
"""Divide the num1 by num2, returning a floating point."""
return num1 / num2
def square(num1):
"""Return the square of num1."""
return num1 * num1
def cube(num1):
"""Return the cube of num1."""
return num1 * num1 * num1
def power(num1, num2):
"""Raise num1 to the power of num2 and return the value."""
return num1 ** num2 # ** = exponent operator
def mod(num1, num2):
"""Return the remainder of num1 / num2."""
return num1 % num2