CBSE Class 11 Computer Science
Question 133 of 173
Data Handling — Question 22
Back to all questions 22
Question Question 17
Predict the output if e is given input as 'True':
a = True
b = 0 < 5
print (a == b)
print (a is b)
c = str (a)
d = str (b)
print (c == d)
print (c is d)
e = input ("Enter :")
print (c == e)
print (c is e)Answer
Output
True
True
True
True
Enter :True
True
False
Explanation
- As 0 < 5 is True so b value of b becomes True and its type is bool.
print (a == b)gives True as a and b both are True.print (a is b)gives True as a and b both being True point to the same object in memory.- Similarly
print (c == d)andprint (c is d)give True as c and d both are string and point to the same object in memory. - The user input for e is True so e is of type string having value "True".
- As value of strings c and e is "True" so
print (c == e)gives True. - Even though the values of strings c and e are same, they point to different objects in memory so
print (c is e)gives False.