nick34992
5/2/2017 - 11:08 PM

Python: Vector Class: math.hypot()

Python: Vector Class: math.hypot()

import math

class Vector:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def length(self):
        return math.hypot(self.x, self.y)

v = Vector(3, 4)
print(v.length())  # 5.0