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
Working with Large Numbers:
print(math.trunc(123456.789)) # Output: 123456
Using with Variables:
x = 45.67
print(math.trunc(x)) # Output: 45
import math
print(math.trunc(3.9)) # Output: 3
print(math.trunc(-3.9)) # Output: -3
print(math.floor(3.9)) # Output: 3
print(math.floor(-3.9)) # Output: -4
print(math.ceil(3.1)) # Output: 4
print(math.ceil(-3.1)) # Output: -3
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.