Предизвикателства > 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 WitchMixin:
 3       
 4        def is_a_witch(self):
 5            if hasattr(self, mass_attr_name) and getattr(self, mass_attr_name) == mass:
 6                return "Burn her!"
 7            elif hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material:
 8                return "Burn her!"
 9            elif hasattr(self, float_method_name) and callable(getattr(self, float_method_name)):
10                return "Burn her!"
11            else:
12                return "No, but it's a pity, cuz she looks like a witch!"
13            
14
15    return WitchMixin

.
----------------------------------------------------------------------
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):
n2    class WitchMixin():n2    class WitchMixin:
3       3       
4        def is_a_witch(self):4        def is_a_witch(self):
5            if hasattr(self, mass_attr_name) and getattr(self, mass_attr_name) == mass:5            if hasattr(self, mass_attr_name) and getattr(self, mass_attr_name) == mass:
6                return "Burn her!"6                return "Burn her!"
7            elif hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material:7            elif hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material:
8                return "Burn her!"8                return "Burn her!"
9            elif hasattr(self, float_method_name) and callable(getattr(self, float_method_name)):9            elif hasattr(self, float_method_name) and callable(getattr(self, float_method_name)):
10                return "Burn her!"10                return "Burn her!"
11            else:11            else:
12                return "No, but it's a pity, cuz she looks like a witch!"12                return "No, but it's a pity, cuz she looks like a witch!"
13            13            
1414
15    return WitchMixin15    return WitchMixin
t16                t
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op