This is the first challenge of the "Four Vectors" collection. Four Vectors are vectors with four components that are used to describe relativistic physics. For details please refer to this wiki entry.
In this challenge, create a class FourVector with the following properties:
[0.0, 0.0, 0.0, 0.0].GetComponents and SetComponents, see test cases(0.5, 1.0, -2.0, 10.0) where the components are rounded to three decimal places.Consider using magic methods like __add__, __eq__ and __str__ to solve the last three bullet points.
v = FourVector([1, 2, 3, 4])
print(v) ➞ (1, 2, 3, 4)
v2 = FourVector([1, 0, 1, 0])
print(v + v2) ➞ (2, 2, 4, 4)
Please save your FourVector class for later use, we will add new methods in upcoming challenges in this series!