Предизвикателства > She's a witch! > Решения > Решението на Гергана Благоева

Резултати
1 точки от тестове
0 точки от учител

1 точки общо

1 успешни теста
0 неуспешни теста
Код

 1def logic_mixin_factory(mass: int, mass_attr_name: str, material: str, material_attr_name: str, float_method_name: str):
 2    class WitchDetector:
 3        def is_a_witch(self):
 4            if (mass == getattr(self, mass_attr_name, None) or 
 5                material == getattr(self, material_attr_name, None) or 
 6                callable(getattr(self, float_method_name, None))):
 7                return "Burn her!"
 8            else:
 9                return "No, but it's a pity, cuz she looks like a witch!"
10    return WitchDetector

.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

Дискусия
История

f1def logic_mixin_factory(mass: int, mass_attr_name: str, material: str, material_attr_name: str, float_method_name: str):f1def logic_mixin_factory(mass: int, mass_attr_name: str, material: str, material_attr_name: str, float_method_name: str):
2    class WitchDetector:2    class WitchDetector:
3        def is_a_witch(self):3        def is_a_witch(self):
t4            if mass == getattr(self, mass_attr_name, None) or material == getattr(self, material_attr_name, None) or callable(getattr(self, float_method_name, None)):t4            if (mass == getattr(self, mass_attr_name, None) or 
5                material == getattr(self, material_attr_name, None) or 
6                callable(getattr(self, float_method_name, None))):
5                return "Burn her!"7                return "Burn her!"
6            else:8            else:
7                return "No, but it's a pity, cuz she looks like a witch!"9                return "No, but it's a pity, cuz she looks like a witch!"
8    return WitchDetector10    return WitchDetector
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op