Загрузка...

class and object in python in hindi | object oriented programming in python

In this video you will learn about classes, objects, and constructor in python. Class and Objects Python have support for object oriented programming also. So we can implement and use all major concepts of Object Oriented Programming like Class, Object, Inheritance, and Polymorphism etc. Class A class is a blueprint or template for creating object. A class is a user defined data type that can contain both variables and functions. The variables are called data members and functions are called member method. The data member of class are accessed by a special parameter inside the member method. This parameter is the first parameter in every member method. Generally name of this parameter is “self” but you can use any other name also. A class is only a logical construct. It only describes what values can object hold and what methods can be called by the objects. To create a class the class keyword is used. It have following syntax: class Classname: #functions-or-member-methods Object An object is an instance of the class. It have all the data members and member functions defined by the class. An object takes space in memory and have actual physical existence. So an object is required to use the members of the class. To create an object of class we use following syntax: objectname= classname() To use the member using object we use member access operator (. Operator) between object name and member name: objectname.function(parameter) objectname.variable Constructor or __init__ method of the class A constructor is a special member of class which is used to create the object of the class. It can also be used to initialize the data members of the class. In python a constructor have a special name “__init__”. When we create an object of the class, this is automatically called. s=Student() #Automatically-calls-the __init__-method-and-create-the-object. Q. i) WAP to create a class to represent student ii)define __init__ in the class. iii) initialize three data members : name, roll_number, and age in __init__ iv) define print_details function and print name,roll_number, and age v) Create an object vi)print details by calling print_details function with object #python_by_tarun_sir #tarun_sir #python #tarun_sir_python #python_video_62 #class_and_objects_in_python #python_tutorial #constructor_in_python

Видео class and object in python in hindi | object oriented programming in python автора Кодовая Грань
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять