Kursinhalt
Object-Oriented Programming in Python
Object-Oriented Programming in Python
1. Classes and Objects
2. Encapsulation
3. Inheritance
4. Polymorphism
Polymorphism
Polymorphism is a class property to modify superclass functionality. Methods or attributes can have various meanings and purposes inside the different classes. Methods in the superclass are virtual, that means they can be overridden in the children's classes.
Code
Each class has the say
method. But each method performs different things.
class Bird: def say(self): print('Chirp') class Duck(Bird): def say(self): print('Quack') class Rooster(Bird): def say(self): print('Cock-a-doodle-do') bird = Bird() bird.say() duck = Duck() duck.say() rooster = Rooster() rooster.say()
War alles klar?
Danke für Ihr Feedback!
Abschnitt 4. Kapitel 1