-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathw3school_pythonmath.py
More file actions
51 lines (36 loc) · 963 Bytes
/
w3school_pythonmath.py
File metadata and controls
51 lines (36 loc) · 963 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
50
# Python Math
# Python has a set of built-in math functions, including an extensive math module, that allows you to perform mathematical tasks on numbers
# Built-in Math functions
# E.g. The min() and max() functions can be used to find the lowest or highest value is an iterable:
"""
x = min(5,10,25)
y = max(5,10,25)
print(x)
print(y)
"""
# E.g. the abs() function returns the absolute(positive) value of the specified number:
"""
print(abs(-7.25))
"""
# E.g. the pow(x,y) functions the value of x to the power of y
"""
print (pow(4,3))
"""
# The math module
# Python has also a built-in module called math, which extends the list of mathematical functions.
# E.g.
"""
import math
print(math.sqrt(64))
"""
# E.g. the math.ceil() method rounds a number upwards to its nearest integer and math.floor() rounds a number downward
"""
import math
print(math.ceil(1.4))
print(math.floor(1.4))
"""
# E.g. pi
"""
import math
print(math.pi)
"""