# Python operator.ge() Function with Examples

Python operator.ge() Function: Here, we are going to learn about the operator.ge() function with examples in Python programming language.
Submitted by IncludeHelp, on April 14, 2020

## operator.ge() Function

operator.ge() function is a library function of operator module, it is used to perform "greater than or equal to operation" on two values and returns True if the first value is greater than or equal to the second value, False, otherwise.

Module:

```    import operator
```

Syntax:

```    operator.ge(x,y)
```

Parameter(s):

• x,y – values to be compared.

Return value:

The return type of this method is bool, it returns True if x is greater than or equal to y, False, otherwise.

Example 1:

```# Python operator.ge() Function Example

import operator

# integers
x = 10
y = 20

print("x:",x, ", y:",y)
print("operator.ge(x,y): ", operator.ge(x,y))
print("operator.ge(y,x): ", operator.ge(y,x))
print("operator.ge(x,x): ", operator.ge(x,x))
print("operator.ge(y,y): ", operator.ge(y,y))
print()

# strings
x = "Apple"
y = "Banana"

print("x:",x, ", y:",y)
print("operator.ge(x,y): ", operator.ge(x,y))
print("operator.ge(y,x): ", operator.ge(y,x))
print("operator.ge(x,x): ", operator.ge(x,x))
print("operator.ge(y,y): ", operator.ge(y,y))
print()

# printing the return type of the function
print("type((operator.ge(x,y)): ", type(operator.ge(x,y)))
```

Output:

```x: 10 , y: 20
operator.ge(x,y):  False
operator.ge(y,x):  True
operator.ge(x,x):  True
operator.ge(y,y):  True

x: Apple , y: Banana
operator.ge(x,y):  False
operator.ge(y,x):  True
operator.ge(x,x):  True
operator.ge(y,y):  True

type((operator.ge(x,y)):  <class 'bool'>
```

Example 2:

```# Python operator.ge() Function Example
import operator

# input two numbers
x = int(input("Enter first number : "))
y = int(input("Enter second number: "))

# printing the values
print("x:",x, ", y:",y)

# comparing
if operator.ge(x,y):
print(x, "is greater than or equal to", y)
else:
print(x, "is not greater than or equal to", y)
```

Output:

```RUN 1:
Enter first number : 20
Enter second number: 10
x: 20 , y: 10
20 is greater than or equal to 10

RUN 2:
Enter first number : 10
Enter second number: 10
x: 10 , y: 10
10 is greater than or equal to 10

RUN 3:
Enter first number : 10
Enter second number: 20
x: 10 , y: 20
10 is not greater than or equal to 20
```

Comments and Discussions!

Student's Section
Subscribe

Copyright © 2024 www.includehelp.com. All rights reserved.