Comparison Operators in Python Class 11 Important Notes with Questions

Share with others

Comparison Operators in Python

What are Operators ?

Operators are special symbols which perform a special task on values or variables. Same operator can behave differently on different data types.

What do you mean by Operand?

Operands are the values or variables on which the operator operate.

What do you mean by Expression in python?

Operators when applied on operands form an expression. for example

a = c – d

Identify the operator and operand in the following expression.

1) d = a * b

Here d, a, b are operands and = , * are operators

2) c = a + b

Here c, a, b are operands and =, + are operators

Operators are categorized as

1. Arithmetic

2. Relational

3. Logical

4. Assignment

Relational/Comparison Operators

Those operator which help to compare two or more values/variables are called Comparison Operators. The output of comparison operator is Boolean value(True or False).

SymbolNameCodingOutput
>Greater than>>> 6 > 9

>>> ‘CS’ > ‘cs’

>>> 2.4 > 5

>>>3.5 > (2.5 + 2)

>>> 2.5 > ‘CS’
True

False

False

False

TypeError
<Less than>>> 9 < 2

>>> 7.5 < 12

>>> 10.6 < 5.6
False

True

False
>=Greater than equal to>>> 2 >= 6

>>> 5.2 >= 5.2

>>> “Hello” >= 2

>>> “Hello” >= “Hello”
False

True

TypeError

True
<=Less than equal >>> 7 <= 2

>>> 7.0 <= 2

>>> ‘IP’ <= ‘ip’
False

False

True
!=Not equals to>>> 7 != 2

>>> ‘CS’ != ‘Cs’
True

True
==Equals to>>> 2 == 3

>>> 2.0 == 3.0

>>> ‘CS’ == ‘Cs’
False

False

False
Comparison Operators in Python

Q1. Evaluate the following

a) >>> 7 + 5 >= 10

Ans. True

b) >>> “Anil” > “anil”

Ans. False

c) >>> 25 % 3 == 2

Ans. False

d) >>> 23 // 7 >= 9

Ans. False

e) >>> 7 + 3 % 2 != True

Ans. True

f) >>> False == False

Ans. True

g) >>> True != False

Ans. True

h) >>> 78 % 9 % 2 == 0

Ans. True

i) >>> 29 == 89 % 30

Ans. True

j)>>> 45 // 68 % 2 == True

Ans. False


Disclaimer : I tried to give you the correct explanation of “Comparison Operators in Python ” , but if you feel that there is/are mistakes in the explanation of “Comparison Operators in Python given above, you can directly contact me at csiplearninghub@gmail.com.


Class 12 Computer Science Sample Paper 2020-2021.

Class 12 Computer Science Sample Paper Marking Scheme

Class 12 Computer Science Test Series


Share with others

Leave a Reply

error: Content is protected !!