[Python] Can you explain me the output

Discussão em 'Python' iniciado por Stack, Julho 15, 2025.

  1. Stack

    Stack Membro Participativo

    I was in class section of python programming and I am confused here.

    I have learned that super is used to call the method of parent class but here Employee is not a parent of Programmer yet it's called (showing the result of getLanguage method).

    What I am missing?

    This is the code,

    class Employee:
    company= "Google"
    language = "java"
    def showDetails(self):
    print("This is an employee");

    def getLanguage(self):
    print(f"1. The language is {self.language}");


    class Programmer:
    language= "Python"
    company = "Youtubeeee"
    def getLanguage(self):
    super().getLanguage();
    print(f"2. The language is {self.language}")

    def showDetails(self):
    print("This is an programmer")



    class Programmer2(Programmer , Employee):
    language= "C++"
    def getLanguage(self):
    super().getLanguage();
    print(f"3. The language is {self.language}")



    p2 = Programmer2();
    p2.getLanguage();


    This is the output,

    1. The language is C++
    2. The language is C++
    3. The language is C++

    Continue reading...

Compartilhe esta Página