Back to Freecodecamp

Step 2

curriculum/challenges/english/blocks/learn-special-methods-by-building-a-vector-space/65f03d9f92eac9183a4d3281.md

latest1.1 KB
Original Source

--description--

A vector can be defined by two coordinates, x and y, in the Euclidean plane. The distance between the origin of the axes and the point (x, y) will be its length, or norm. And the vector direction will point towards (x, y).

Within the Vector class, create an __init__ method and give it three parameters, self, x, and y.

--hints--

You should define an __init__ method inside the Vector class.

js
({ test: () => assert(runPython(`_Node(_code).find_class("Vector").has_function("__init__")`)) })

Your __init__ method should take three parameters: self, x, and y.

js
({ test: () => assert(runPython(`_Node(_code).find_class("Vector").find_function("__init__").has_args("self, x, y")`)) })

--seed--

--seed-contents--

py
--fcc-editable-region--
class Vector:
    pass
--fcc-editable-region--