Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn Python DUCK TYPING in 4 minutes! ๐Ÿฆ†
Play lesson

Python tutorial for beginners ๐Ÿ - Learn Python DUCK TYPING in 4 minutes! ๐Ÿฆ†

4.0 (0)
8 learners

What you'll learn

This course includes

  • 14.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

# "Duck typing" = Another way to achieve polymorphism besides Inheritance # Object must have the minimum necessary attributes/methods # "If it looks like a duck and quacks like a duck, it must be a duck." class Animal: alive = True class Dog(Animal): def speak(self): print("WOOF!") class Cat(Animal): def speak(self): print("MEOW!") class Car: alive = True def speak(self): print("HONK!") animals = [Dog(), Cat(), Car()] for animal in animals: animal.speak() print(animal.alive)

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere