Code 29: trunc() in Python | Remove Decimal part in a value | Math Module | 365 days in Code

Published: 29 January 2021
on channel: Code House
1,034
12

Mistake - Ignore the "floor", it will be trunc.
The math.trunc() method returns the truncated integer part of a number.
It simply remove the decimals part.
Ex - trunc of 7.9 will be 7.
Ex - trunc of 19.1 will be 19.
Ex - trunc of -7.3 will be -7.

Code -
import math # Import the math module
print(math.trunc(7.9)) # 7
print(math.trunc(19.1)) # 19
print(math.trunc(-7.3)) # -7

Thanks


On this page of the site you can watch the video online Code 29: trunc() in Python | Remove Decimal part in a value | Math Module | 365 days in Code with a duration of hours minute second in good quality, which was uploaded by the user Code House 29 January 2021, share the link with friends and acquaintances, this video has already been watched 1,034 times on youtube and it was liked by 12 viewers. Enjoy your viewing!