1
0
forked from tdwojak/Python2017
Python2017/labs04/task03.py
2017-12-16 09:01:07 +01:00

38 lines
979 B
Python

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
def is_numeric(InputList):
OutputLits = []
for i in range(len(InputList)):
t = InputList[i]
OutputLits.append(isinstance(t,(int, float)))
#print(isinstance(x,(int, float)))
return OutputLits
class Point:
def __add__(self, other):
if len(self.cor)!=len(other.cor):
raise DimensionError("DimesnsionError")
else:
return [i+j for (i,j) in zip(self.cor,other.cor)]
def __init__(self, cor):
if (is_numeric(cor)):
self.cor=cor
else:
raise Exception("Wrong input")
def __len__(self):
return len(self.cor)
def __str__(self):
return(str(self.cor))
def __to_string__(self):
return(str(self.cor))
class DimensionError(Exception):
def __init__(self, text):
self.text = text
def __str__(self):
return self.text
test=Point([2,5])
print(str(test))
print(len(test))