Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
math.trunc()
communitycreator

How math.trunc() works in Python

Hassan Ahmed

The built-in math.trunc() function from the math module in Python is used to truncate values and return their fragments, also called integers.

Syntax

math.trunc(x)

Parameter

The function math.trunc() requires a number to be passed as a parameter. The number is returned with its decimal value removed.

Return value

A TypeError is raised if the passed parameter is not a number value.

Code

import math

print(math.trunc(9.11))
print(math.trunc(1.11))
print(math.trunc(4.20))

RELATED TAGS

python
math.trunc()
communitycreator
RELATED COURSES

View all Courses

Keep Exploring