Python‎ > ‎math‎ > ‎

math.trunc()

http://www.adilwaseem.com/

Definition
Return with the round value of x omitting fractions.

Syntax
math.trunc(x)

Parameters
x=number

Examples
The method round the values:
 >>> math.trunc(22.2112)
22
>>> math.trunc(62.332)
62
>>>

for statement
Method run the loop for sets.
import math
set1={math.trunc(1.1),math.sqrt(49),math.pow(4,2),math.e,math.exp(44)}
set2={math.floor(3.12),math.fmod(3,2),math.fabs(22), math.ceil(1)}
for i in map(lambda a,b: a+b, set1, set2):
print(i)

>>> 
17.0
4
24.718281828459045
>>>


if statement sum(map(lambda).__le__()
The lambda returns with equation computation.
import math
x=[math.log(2,10),math.log10(22), math.log2(2)]
y=[math.trunc(2.1)]
if sum(map(lambda a,b: a+b/2, x,y)).__le__(y):
    print("The return is large or equal to 2.0")
else:
    print("The value does not meet the criteria")

>>> 
The return is large or equal to 2.0
>>>


Comments