truncate in python code example
Example 1: remove decimal python
# Truncates a double to an int
i = 10.0
k = int(i)
# i = 10.0
# k = 10
Example 2: python truncate
import math
print(math.trunc(4.95*5.1))
# 25
Example 3: truncate toward zero python
>>> int(float(-1)/2)
0
>>> int(float(-3)/2)
-1
>>> int(float(1)/2)
0
>>> int(float(3)/2)
1