Python‎ > ‎operator‎ > ‎

operator.ge()

http://www.adilwaseem.com/

Return
Return with the test whether one value is equal or greater than other.

Syntax
operator.ge(a,b)
__ge__

Parameters
a,b=number

Examples
The method tested whether first parameter is greater or equal to other.
 >>> a=99.01
>>> b=100.00
>>> operator.ge(a,b)
False
>>> operator.ge(b,a)
True

a>=b
Return the above mention test.
 >>> a=99.01
>>> b=100.00
>>> a>=b
False
>>> b>=a
True

 operator.__ge__(a,b)
The results are same.
 >>> a=99.01
>>> b=100.00
>>> operator.__ge__(a,b)
False
>>> operator.__ge__(b,a)
True

The equal to:
 from decimal import Decimal
import operator

a=Decimal(1.4).min(Decimal(1))
b=Decimal(1.3).min_mag(1)
z=operator.ge(x,y)
print("The value of a is greater and equal to b:", z)
>>>
The value of a is greater and equal to b: True
>>> 


The method returns with the value:
import random
x=random.Random()
if x.__ge__(2):
                    print("Random value are not acceptable")
else:
     print(x)
>>> 
Random value are not acceptable
>>>


__ge__
The return is:
import operator
import random
a=float(random.randrange(1,10))
b=float(random.randint(20,40))
c=operator.pow(a,b)
if c.__le__(10):
    print("Random value: ",c+5)
elif c.__ge__(20):
    print("Random value: ",c-5)





Comments