+ 1

Is this code right for inheritances in python 3????

multilevel: class pizaa: def cheese(self): print("100/-") def vegie(pizaa): print("90/-") def base(vegie): print("200/-") p=pizaa() p.cheese() p.vegie() p.base() o/p: 100/- 90/- 200/- Multiple: class pizaa: class cheese(): print("100") class vegie(): print("90") class base(cheese,vegie): print("200") p=pizaa() p.cheese() p.vegie() p.base() o/p: 100 90 200 Hierarchical: class cheese(): print("100") class vegie(cheese): print("90") class base(cheese): print("200") p=base() o/p: 100 90 200

13th Feb 2019, 3:28 PM
Disha Sanjay Sakre
Disha Sanjay Sakre - avatar
1 Réponse
+ 1
Multilevel inheritance means a class will inherit some class and then some other will inherit this class and so. Eg. class One(): pass class Two(One) : pass class Three(Two): pass class Four(Three): pass So on... In multiple inheritance, a class will inherin more than one class Eg. class One() : pass class Two(): pass class Three(One, Two): pass
23rd Feb 2019, 3:32 AM
Шащи Ранжан
Шащи Ранжан - avatar