Oops concepts in python with examples

broken image
broken image

The Student() class may have the characteristics like name, age or subject but it will not declare any information regarding the attributes. You must remember that a class is just a blueprint as is just provides the structure of how something should be defined, but it isn’t a real object itself. In case of a student information, we should create a Student() classes to include different characteristics of the student like name, age or subjects. How are going to make sure that all the students have name or age and so on? What if you want to add other attributes to the student information as well?Ĭlasses are used to create a custom defined data structure that is going to cater the user’s need in order to obtain information about something. How would you know that which element is required for which student. If you want to go according to the list then you would end up creating different lists like their names, ages, roll number subjects grades etc.

broken image

Let’s say that we want to represent information of school students. We have learned so far that Python includes data structures like: strings, lists numbers etc but what if we want to present something more complicated. In order to understand a Class, we need to focus on an object first because an object is an instance (part) of a class.

broken image