How do you truncate all numbers after a decimal in Python 3?
For example truncate 3.444 to be just 3.
Round a number down by using the ROUNDDOWN function. It works just the same as ROUND, except that it always rounds a number down. For example, if you want to round down 3.14159 to three decimal places: =ROUNDDOWN(3.14159,3) which equals 3.141.
Using DecimalFormat ##" . This means it limits the decimal place up to 2 digits.
By converting it to an int
:
>>> num = 3.444
>>> int(num)
3
>>> import math
>>> num = 3.4444
>>> math.trunc(num)
3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With