CBSE Class 11 Computer Science Question 116 of 173

Data Handling — Question 5

Back to all questions
5
Question

Question 4b

What will following code print?

a = 3
b = 3.0
print (a == b)
print (a is b)

Answer

This Python code prints:

True
False

As values of a and b are equal so equality operator returns True. a is of int type and b is of float type so a and b are different objects so a is b returns False.

Answer