Python‎ > ‎operator‎ > ‎

### operator.lt()

Definition
Return whether a is lesser than b.

Syntax
operator.lt(a,b)
operator.__lt__(a,b)

Parameters
a,b=values

Examples
The method return with comparison.
 >>> set1={4,5,6,7}>>> set2={6,7,8,9,10}>>> operator.lt(set1,set2)False>>>

__lt__
The method tested whether the set1 is lesser than set2.
 >>> set1={4,5,6,7}>>> set2={6,7,8,9,10}  >>> set1.__lt__(set2)False

The return is:
 from decimal import Decimalimport operatora=Decimal(1).radix()b=Decimal(1.3).next_toward(2)y=operator.lt(a,b)print("The value a lesser than b: ", y)>>>The value a lesser than b: False>>>

if variable (__lt__) varible
The method selected the item from tuple.
 import randomtuple=(1,3,5,7,4,6,7)if x.__lt__(4):                  print("Random value is lessor than 4")else:      print("Random value is: ",x)>>> Random value is: 6>>>

if operator.xor(a,b)__lt__()
The method binary bit value of a, not in b after applying the round() method to Decimal().conjugate() and Decimal().copy_abs()
 import operatorfrom decimal import*b=round(Decimal(-133).copy_abs())if operator.xor(a,b).__lt__(300):    print(" Binary the bit set in", a, "not in" ,b, "is", operator.xor(a,b))else:>>> Binary the bit set in 33 not in 133 is 164>>>

set(Decimal()).__lt__set(Decimal())
The returns are following:
 from decimal import Decimalimport itertoolsset1={Decimal(0.1).to_integral_value(),Decimal(1.9).to_integral_exact(),                        Decimal(1.5000001).to_integral(), Decimal(10).shift(2)}set2={Decimal(1).scaleb(0),Decimal(1).remainder_near(2),Decimal(1.0000).normalize()}print("The decimal values of set1 are:", set1)print("The decimal values of set2 are: ", set2)max_set1=int(max({Decimal(0.1).to_integral_value(),Decimal(1.9).to_integral_exact(),Decimal(1.5000001).to_integral(), Decimal(10).shift(2)}))print("The maximum integer value in set1 is: ",max_set1)min_set2=int(min({Decimal(1).scaleb(0),Decimal(1).remainder_near(2),Decimal(1.0000).normalize()}))print("The minimum integer value in set2 is:",min_set2)set3=max_set1.__add__(min_set2)print("The set1 added by set2 is: ", set3) set4=max_set1.__lt__(min_set2)print("The max_set1 is lessor than min_set2:", set4)x=set1.difference(set2)print("The set1 difference to set2 is :", x)>>> The decimal values of set1 are: {Decimal('1000'), Decimal('0'), Decimal('2')}The decimal values of set2 are: {Decimal('1')}The maximum integer value in set1 is: 1000The minimum integer value in set2 is: 1The set1 added by set2 is: 1001The max_set1 is lessor than min_set2: FalseThe set1 difference to set2 is : {Decimal('1000'), Decimal('0'), Decimal('2')}>>>

class method executed the if statement about accumulated value of value1 and value2.
 import operatorclass add_value:    def __init__(self,a,b):        self.a=a        self.b=b        self.c=a+b        if self.c.__lt__(20):            print("The values added are more lesser than required parameters:",self.c)        else:            print("Values added: ", self.c)                                  value1=33value2=33.1add_value(value1, value2)>>> Values accepted: 66.1>>>