Skip to content
CodeKruPro

An overridden method called from the parent __init__

Predict the outputHardPython only
main.py
class Base:
    def __init__(self):
        self.setup()

    def setup(self):
        print("base setup")

class Child(Base):
    def __init__(self):
        super().__init__()
        self.size = 5

    def setup(self):
        print("child setup, has size:", hasattr(self, "size"))

c = Child()
c.setup()

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in