Derived overrides a method
Input
compare_methods(Animal, Dog, 'speak')
Output
('...', 'woof', 'overridden')
Animal.speak returns '...'; Dog overrides speak to return 'woof'. The function reports both outputs and 'overridden'.
Full lesson preview
Determine whether a derived class method is overridden or inherited and compare runtime results.
Problem statement
Task
Examples
Input
compare_methods(Animal, Dog, 'speak')
Output
('...', 'woof', 'overridden')
Animal.speak returns '...'; Dog overrides speak to return 'woof'. The function reports both outputs and 'overridden'.
Input format
Output format
Constraints
Samples
Input
compare_methods(BaseMath, MultChild, 'compute', 2, 3)
Output
(5, 6, 'overridden')
BaseMath.compute returns 2+3=5; MultChild overrides compute to multiply and returns 6.