Q:

Write a python code that explains the Polymorphism?

0

Write a python code that explains the Polymorphism?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

class Bird: 
  def intro(self):
    print("We are birds!") 
  
  def flight(self): 
    print("Wow we can fly but some cannot.")
  
class crow(Bird): 
  def flight(self): 
    print("Crows can fly.") 
  
class ostrich(Bird): 
  def flight(self): 
    print("Ostriches cannot fly.") 
  
obj_bird = Bird() 
obj_cro = crow() 
obj_ost = ostrich() 
obj_bird.intro() 
obj_bird.flight() 
obj_cro.intro() 
obj_cro.flight() 
obj_ost.intro() 
obj_ost.flight() 

Output:

We are birds!
Wow we can fly but some cannot.
We are birds!
Crows can fly.
We are birds!
Ostriches cannot fly.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now