1
0
forked from tdwojak/Python2017

labs04 z1

This commit is contained in:
s45148 2017-12-16 00:19:41 +01:00
parent 03bcc26529
commit 0884ab90a3
3 changed files with 50 additions and 8 deletions

View File

@ -8,3 +8,5 @@ def is_numeric(InputList):
OutputLits.append(isinstance(t,(int, float))) OutputLits.append(isinstance(t,(int, float)))
#print(isinstance(x,(int, float))) #print(isinstance(x,(int, float)))
return OutputLits return OutputLits
print(is_numeric([-1,2.4,6]))

View File

@ -2,4 +2,27 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class Employee: class Employee:
def __init__(self, ,): _id = 0
def __init__(self, name, surname):
Employee._id += 1
self.id = Employee._id
self.name = name
self.surname = surname
def get_id(self):
return self.id
class Recruiter(Employee):
recruited = []
def recruit(self, Employee):
emp_id = Employee.id
self.recruited.append(emp_id)
class Programmer(Employee):
def __init__(self, name, surname, Recruiter):
super().__init__(name, surname)
self.recruiter = Recruiter.id

View File

@ -1,19 +1,36 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
def is_numeric(InputList): def is_numeric(InputList):
OutputLits = [] OutputLits = []
for i in range(len(InputList)): for i in range(len(InputList)):
t = InputList[i] t = InputList[i]
OutputLits.append(isinstance(t,(int, float))) OutputLits.append(isinstance(t,(int, float)))
#print(isinstance(x,(int, float)))
return OutputLits return OutputLits
class Point: class Point:
def __init__(self, StartList): def __add__(self, other):
self.StartList = StartList 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 retx(self): class DimensionError(Exception):
return self def __init__(self, text):
self.text = text
def __str__(self):
return self.text
x = Point([2]) test=Point([2,5])
print(x.retx()) print(str(test))
print(len(test))