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()

Post your comments , suggestion , error , requirements etc here

Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2021 All rights reserved worldwide Privacy Policy Disclaimer