0% found this document useful (0 votes)
4 views1 page

Creating a Child Class in Python

The document outlines the process of creating a child class 'Bus' that inherits from a base class 'Vehicle'. It describes the use of the __init__ function and instance variables to define attributes, and the implementation of the pass statement to inherit the parent class's attributes. The document concludes with instructions for presenting the results of the object's inherited attributes.

Uploaded by

carpiomelody52
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Creating a Child Class in Python

The document outlines the process of creating a child class 'Bus' that inherits from a base class 'Vehicle'. It describes the use of the __init__ function and instance variables to define attributes, and the implementation of the pass statement to inherit the parent class's attributes. The document concludes with instructions for presenting the results of the object's inherited attributes.

Uploaded by

carpiomelody52
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

 an error even when we execute a program which shows in our output.

For the number 3, we are required to create a child class ‘Bus’


that will inherit all of the variables and methods of the base class.
First we started with the header of the program “This is a Child Class
Bus”.
Then next is the given Vehicle class.
We use the __init__ function and instance variables to start the
attributes. Following that, we created the child class which is the ‘BUS’.
We used the pass statement because we only want to inherit the
attributes of the parent class.
Following that, we created our object and assigned values to it. Finally,
we used the print function and manually called each value to output
the object's inherited attributes that we had previously created.
For the next slide we have Mr. Calamba to present it.

You might also like