Inheritance Example in Python

Publié le: 19 janvier 2022
sur la chaîne: Nuruzzaman Faruqui
825
13

In object-oriented programming, inheritance is the procedure in which one class inherits the attributes and methods of another class. The class whose properties and methods are inherited is known as the Parent class. And the class that inherits the properties from the parent class is the Child class.

By a laptop with discount to code in Python: https://amzn.to/3H8gdig

In this lesson, we will learn the concept of inheritance through an example coded in python.

Here is the code used in this example:

class Laptop:
def parts(self):
print('Keyboard, Display, Motherboard')


my_laptop = Laptop()
my_laptop.parts()


class Desktop(Laptop):
def weight(self):
print('Desktops are heavy-weight')

my_desktop = Desktop()
my_desktop.parts()
my_desktop.weight()


Sur cette page du site, vous pouvez voir la vidéo en ligne Inheritance Example in Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Nuruzzaman Faruqui 19 janvier 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 825 fois et il a aimé 13 téléspectateurs. Bon visionnage!