Python math.trunc() Method

Python math.trunc() method “returns the truncated integer part of a number.” For example, if the number is 3.14, the math.trunc() method will return 3.

Syntax

math.trunc(x)

Parameters

  1. x: The number to be truncated.

Return value

It returns the truncated integer part of x.

Time Complexity: O(1)

Auxiliary Space: O(1)

Example: How to Use math.trunc() Method

import math

print(math.trunc(3.14))

print(math.trunc(-1.23))

Output

3
-1

That’s it.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.