3 , , - :
import math
vector3 = [5, 6, -7]
print math.sqrt(vector3[0]**2 + vector3[1]**2 + vector3[2]**2)
, , :
import math
vector3 = [5, 6, -7]
print math.sqrt(sum(c ** 2 for c in vector3))
Length :
import math
class Vector3(object):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
@property
def Length(self):
return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
vector3 = Vector3(5, 6, -7)
print vector3.Length