πŸ“Š Python
Q. What is output of the following code?
Code:
class A:
    def __init__(self, x):
        self.x = x
    def __eq__(self, other):
        return self.x == other.x

a = A(5)
b = A(5)
print(a == b)
  • (A) True
  • (B) False
  • (C) Error
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (A) True

Explanation: `__eq__` method compares the values of `x` in both objects, so returns True.

Explanation by: Mr. Dubey
`__eq__` method compares the values of `x` in both objects, so returns True.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
59
Total Visits
πŸ“½οΈ
10 mo ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
80%
Success Rate