Стела обнови решението на 01.04.2013 16:34 (преди над 11 години)
+people = []
+
+
+class Person:
+
+ def __init__(self, name, birth_year, gender, mother=None, father=None):
+ self.name = name
+ self.birth_year = birth_year
+ self.gender = gender
+ self.mother = mother
+ self.father = father
+ people.append(self)
+
+ def get_brothers(self):
+ brothers = []
+ for person in people:
+ if person.gender == "M" and (person.mother == self.mother or person.father == self.father):
+ brothers.append(person)
+ return brothers
+
+ def get_sisters(self):
+ sisters = []
+ for person in people:
+ if person.gender == "F" and (person.mother == self.mother or person.father == self.father):
+ sisters.append(person)
+ return sisters
+
+ def children(self, gender=None):
+ my_children = []
+ if gender:
+ for person in people:
+ if person.gender == gender and (person.mother == self or person.father == self):
+ my_children.append(person)
+ else:
+ for person in people:
+ if person.mother == self or person.father == self:
+ my_children.append(person)
+ return my_children
+
+ def is_direct_successor(self, person):
+ if person. mother == self or person.father == self:
+ return True
+ else:
+ return False