πŸ“Š Python
Q. What is the output of the following code?
Code:
class Point:
  
    def __init__(self, x = 0, y = 0):
      self.x = x
      self.y = y
  
    def __sub__(self, other):
        x = self.x + other.x
        y = self.y + other.y
        return Point(x,y)
        
point1 = Point(30, 40)
point2 = Point(10, 20)
point3 = point1 - point2
print(point3.x, point3.y)
  • (A) 20 30
  • (B) 40 60
  • (C) 10 20
  • (D) 20 40
πŸ’¬ Discuss
βœ… Correct Answer: (B) 40 60

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
174
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Rajeev Malhotra
Publisher
πŸ“ˆ
96%
Success Rate