ЁЯУв Too many exams? DonтАЩt know which one suits you best? Book Your Free Expert ЁЯСЙ call Now!


    Question

    The following Python code attempts to call a method from

    the parent class, but it's using an outdated or incorrect syntax. How should it be corrected? class Parent: ┬а ┬а def greet(self): ┬а ┬а ┬а ┬а print("Hello from Parent") class Child(Parent): ┬а ┬а def greet(self): ┬а ┬а ┬а ┬а print("Hello from Child") ┬а ┬а ┬а ┬а # Parent.greet(self) # Problematic c = Child() c.greet()
    A Change `Parent.greet(self)` to `super().greet()`. Correct Answer Incorrect Answer
    B Change `Parent.greet(self)` to `self.greet()`. Correct Answer Incorrect Answer
    C Remove the `greet` method from `Child`. Correct Answer Incorrect Answer
    D Change `Parent` to `Base`. Correct Answer Incorrect Answer
    E The syntax `Parent.greet(self)` is correct and works. Correct Answer Incorrect Answer

    Solution

    The correct answer is A

    Practice Next
    More IT Operating System Questions
    ask-question