trunc(): integer part of a number
trunc() function returns integer part of a number .
Here are some examples with different type of numbers.
import math
print(math.trunc(34.56)) # 34
print(math.trunc(34.21)) # 34
print(math.trunc(34.99)) # 34
print(math.trunc(34)) # 34
Using negative number
import math
print(math.trunc(-34.11)) # -34
print(math.trunc(-34.99)) # -34
print(math.trunc(-34)) # -34
« floor() & ceil()
modf()
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com