what are the different relational operators in python?

Reverend Jim commented: Lazy -3

Recommended Answers

All 4 Replies

Relational operators compare values.

Less than (<) If the value on the left is lesser, it returns True.

 >>>'hi'<'HI'

False.

Greater than (>) If the value on the left is greater, it returns True.

    >>> 1.1+2.2>3.3

True.
This is because of the flawed floating-point arithmetic in Python, due to hardware dependencies.

Less than or equal to (<=) If the value on the left is lesser than or equal to, it returns True.

>>> 3.0<=3

True.

Greater than or equal to (>=) If the value on the left is greater than or equal to, it returns True.

>>> True>=False

True.

Equal to (==) If the two values are equal, it returns True.

>>> {1,3,2,2}=={1,2,3}

True.

Not equal to (!=) If the two values are unequal, it returns True.

>>> True!=0.1

True.

>>> False!=0.1

True.

So you could go to the effort of typing "what are the different relational operators in python" into Daniweb but you couldn't be bothered to google "what are the different relational operators in python" and get the results instantly?

Unbelievable.

commented: I'm running into grads that were forbidden in school to google it. Either that or they think this is Quora.com. +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.