diff --git a/labs04/task01.py b/labs04/task01.py index 121d5a8..0ca3b2d 100644 --- a/labs04/task01.py +++ b/labs04/task01.py @@ -8,3 +8,5 @@ def is_numeric(InputList): OutputLits.append(isinstance(t,(int, float))) #print(isinstance(x,(int, float))) return OutputLits + +print(is_numeric([-1,2.4,6])) \ No newline at end of file diff --git a/labs04/task02.py b/labs04/task02.py index 4e5688f..1f7d4e4 100644 --- a/labs04/task02.py +++ b/labs04/task02.py @@ -2,4 +2,27 @@ # -*- coding: utf-8 -*- class Employee: - def __init__(self, ,): \ No newline at end of file + _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 \ No newline at end of file diff --git a/labs04/task03.py b/labs04/task03.py index 31c9d9d..63f98c7 100644 --- a/labs04/task03.py +++ b/labs04/task03.py @@ -1,19 +1,36 @@ #!/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 __init__(self, StartList): - self.StartList = StartList + 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 retx(self): - return self +class DimensionError(Exception): + def __init__(self, text): + self.text = text + def __str__(self): + return self.text -x = Point([2]) -print(x.retx()) \ No newline at end of file +test=Point([2,5]) +print(str(test)) +print(len(test))