Back to Freecodecamp

Step 8

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

latest531 B
Original Source

--description--

Test that norm works as expected by printing the value returned by the method.

--hints--

You should call norm() on v1 and print the result.

js
({
    test: () => assert(runPython(`_Node(_code).has_call("print(v1.norm())")`))
})

--seed--

--seed-contents--

py
--fcc-editable-region--
class Vector:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        
    def norm(self):
        return (self.x**2 + self.y**2)**0.5

v1 = Vector(2, 3)
--fcc-editable-region--