Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #output:
- #flap flap
- #egg Layed
- #swimmy swimmy
- #walkie walkie
- #eww, worms
- #nom, nom
- #swimmy swimmy
- #swimmy swimmy
- #nom, nom
- class Bird ():
- name="wolly"
- def layEgg (this):
- print "egg Layed"
- def walk (this):
- print "walkie walkie"
- def eatWorms(cls):
- print("eww, worms")
- Bird.eatWorms = classmethod(eatWorms)
- class Duck(Bird):
- def fly (this):
- print "flap flap"
- class Penguin(Bird):
- def swim (this):
- print "swimmy swimmy"
- duck1 = Duck()
- duck1.fly()
- duck1.layEgg()
- penguin1 = Penguin()
- penguin1.swim()
- penguin1.walk()
- penguin1.eatWorms()
- def eatFish(cls):
- print(cls.name+" nom, nom")
- Bird.eatFish = classmethod(eatFish)
- penguin1.eatFish()
- penguin1.swim()
- penguin2=Penguin()
- penguin2.swim()
- penguin2.eatFish()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement