Learn Python OOP - __init__ Method

preview_player
Показать описание
While creating classes, we may need to validate the data. We can validate the data using __init__ method which is also called constructor method in Python. This dunder init method is used to assign values to attributes of our objects.

This constructor method can also take keyword arguments, args and keyword arguments as we can do with any other methods. In this video, we create our own constructor for Person class.

At the end, I have given a challenge based on this video.

Create a Student class with two attribute name and current_education. Also define __init__ method to initialize these values as well as define a sensible describe method which uses these two attribute values.

#Python #ObjectOrientedProgramming #LearnProgramming
If you've successfully created those two methods and complete class, post your answers in the comments section below. I would love to see your implementation of this class.

If you like our content, click on *SUBSCRIBE* button and click on Bell icon to receive latest and greatest updates of my video lessons.

Follow us on Facebook, Twitter, Instagram

Рекомендации по теме