math.floor(): rounds a number down to the nearest integer.
import math
print(math.floor(2.3))# 2print(math.floor(1.89))# 1print(math.floor(7.5))# 7print(math.floor(-10.14))# -11
math.ceil()
math.ceil() rounds a number up to the next largest integer.
import math
print(math.ceil(2.3))# 3print(math.ceil(1.89))# 2print(math.ceil(7.5))# 8print(math.ceil(-10.14))# -10
math.trunc()
math.trunc(): returns the integer part of a number by deleting any fractional digits.
If you're confiused with math.trunc(), math.floor() and math.ceil(), you need to know that math.trunc() plays exactly the role of math.floor() when the giving number is positive, and It play the role of math.ceil() if the giving number is negative.
import math
print(math.trunc(0.000000000000000001))# 0print(math.trunc(2.5))# 2print(math.trunc(8.999999999999999999))# 9print(math.trunc(-7.8))# -7
math.sqrt()
math.sqrt(): returns the square root of the giving positive number.
import math
print(math.sqrt(4))# 2.0print(math.sqrt(25))# 5.0print(math.sqrt(100))# 10.0print(math.sqrt(16))# 4.0
math.degrees()
math.degrees(): this method returns the degrees of a given angle in radians.
import math
pi = math.pi
print(math.degrees(1))# 57.29577951308232print(math.degrees(pi))# 180.0print(math.degrees(pi /2))# 90.0print(math.degrees(pi /4))# 45.0