Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

256
Visualizações
Does Python have polymorphism?

Polymorphism is the ability to take many forms, for example, if the parent class has a method named ABC, it means that the child class can have a method with the same name ABC, containing its own parameters and variables, in python It can be achieved without any affectation or setback in the execution.

over 4 years ago · Juan Sebastián Castellanos Rivillas
1 Respostas
Responde à pergunta

0

Python's point of view is difficult to explain without talking about duck typing , so we recommend reading it.

Being a dynamically typed language and allowing duck typing, in Python it is not necessary for the objects to share an interface, it is simply enough that they have the methods that they want to call.

Suppose we have an Animal class with a hablar() method.

 class Animal: def hablar(self): pass

On the other hand we have two other classes, Perro , Gato that inherit from the previous one. Also, they implement the hablar() method in a different way.

 class Perro(Animal): def hablar(self): print("Guau!") class Gato(Animal): def hablar(self): print("Miau!")

We then create an object of each class and call the hablar() method. We can see that each animal behaves differently when using hablar() .

 for animal in Perro(), Gato(): animal.hablar() # Guau! # Miau!

In the previous case, the animal variable has been “taking the forms” of Perro and Gato . However, note that by having dynamic typing this example would have worked the same without inheritance between Perro and Gato , but we leave this explanation for the chapter on duck typing

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda