# coding=utf-8
import math
class vector(object):
"""docstring for vector"""
"""根据坐标轴列表输入 创建向量, 并创建该向量所处的空间维度"""
def __init__(self, coordinates):
super(vector, self).__init__()
try:
if not coordinates:
raise valueerror
self.coordinates = tuple(coordinates)
self.dimension = len(coordinates)
except valueerror:
raise valueerror('the coordinates must be nonempty')
except typeerror:
raise typeerror('the coordinates must be an iterable')
# '''能够使python的内置print函数 输出向量坐标轴'''
def __str__(self):
return 'vector: {}'.format(self.coordinates)
def __eq__(self, v):
return self.coordinates == v.coordinates
# 计算向量长度
def calculatesize(self):
result =