Q. What will be output produced by following code? State reason for this output.
a, b, c = 1, 1, 2
d = a + b
e = 1.0
f = 1.0
g = 2.0
h = e + f
print(c = d)
print(c is d)
print(g == h)
print(g is h)
Answer =
Output:
True
True
True
False
False: Because python assigns different memory address to floating point values even if there exists a same value in the memory.
While integer values are bound to same memory address.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )