Question OOP-POLY-0012
MediumWhat is the output of this code?
class Vec:
def __init__(self, x, y):
self.x, self.y = x, y
def __add__(self, o):
return Vec(self.x + o.x, self.y + o.y)
v = Vec(1, 2) + Vec(3, 4)
print((v.x, v.y))
- A.
(3, 7)
- B.
(4, 6)
- C.
Sign up free to see the answer and a step-by-step explanation.