+ 1

In the add method what is passed in the self parameter

class Vector2D: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Vector2D(self.x + other.x, self.y + other.y) first = Vector2D(5, 7) second = Vector2D(3, 9) result = first + second print(result.x) print(result.y)

18th Jul 2018, 4:40 PM
adarsh pandey
adarsh pandey - avatar
1 ответ
+ 1
self parameter is for first object and other parameter is for second object. also check this. https://www.sololearn.com/discuss/1405801/?ref=app
18th Jul 2018, 4:55 PM
Maninder $ingh
Maninder $ingh - avatar