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

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

1 точки общо

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

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

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

OK

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

f1def logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name):f1def logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name):
2    class Investigator:2    class Investigator:
3        def is_a_witch(self):3        def is_a_witch(self):
t4            if hasattr(self, mass_attr_name) and getattr(self, mass_attr_name) == mass or \t4            if (hasattr(self, mass_attr_name) and getattr(self, mass_attr_name) == mass or
5                hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material or \5                hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material or
6                    hasattr(self, float_method_name) and callable(getattr(self, float_method_name)):6                    hasattr(self, float_method_name) and callable(getattr(self, float_method_name))):
7                        return "Burn her!"7                        return "Burn her!"
8            8            
9            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!"
1010
11    return Investigator11    return Investigator
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op