Решение на Родословно дърво от Стела Живкова

Обратно към всички решения

Към профила на Стела Живкова

Резултати

  • 0 точки от тестове
  • 0 бонус точки
  • 0 точки общо
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)

Код

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) and person != self:
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) person != self:
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

Лог от изпълнението

File "lib/language/python/runner.py", line 99, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130408-29081-16b9d7c/test.py", line 2, in <module>
    import solution

История (2 версии и 1 коментар)

Стела обнови решението на 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

Стела обнови решението на 01.04.2013 16:53 (преди над 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):
+ if person.gender == "M" and (person.mother == self.mother or person.father == self.father) and person != self:
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):
+ if person.gender == "F" and (person.mother == self.mother or person.father == self.father) person != self:
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