Challenge: Overload the Operators for Vectors
Overload the operators for Vector class.
We'll cover the following...
ed
Press + to interact
class Vector():def __init__(self, vector):self.vector = vectordef print(self):print(self.vector)# Implement this functiondef __neg__(self):return Vector([])
Overload the subtraction operator
Override __sub__()
to overload the -
operator.
Press + to interact
import itertoolsclass Vector():def __init__(self, vector):self.vector = vectordef print(self):print(self.vector)# Implement this functiondef __sub__(self, other):return Vector([])
We hope that you were able to solve the challenge.
Ask