Self and __init__() method in Python | Python Tutorials for Beginners #lec86

Jenny's Lectures CS IT
21 Jul 202317:45

Summary

TLDRIn this video, the speaker continues their Python Object-Oriented Programming series by discussing how to add attributes and initialize objects in a class using the `__init__` method. They explain the role of constructors, the `self` keyword, and how to set default values for attributes like Instagram followers. The video emphasizes simplifying object creation by reducing code lines and concludes with an assignment for viewers to practice creating new objects with attributes. The next video will cover adding methods to the class.

Takeaways

  • 📚 The video continues a Python programming series focusing on object-oriented programming.
  • 🧑‍🏫 The instructor discusses creating classes and objects, building on concepts from the previous video.
  • 🏗️ The key topic in this video is adding attributes to a class and introducing the `__init__` method, which serves as a constructor.
  • 🔑 The `self` keyword is explained as a way to reference the current object when creating attributes or methods within a class.
  • 💡 The purpose of the `__init__` method is to initialize the attributes of an object automatically when the object is created.
  • 🔄 Each time an object is created, the `__init__` method is called to set up the initial state of that object with the given parameters.
  • 📝 Examples are provided on how to add attributes like `name`, `address`, and `followers` to a class and initialize them using the constructor.
  • ❗ The instructor emphasizes that attributes must be accessed using `object.attribute` syntax and demonstrates how this works.
  • 🚀 Default values for attributes (like setting default Instagram followers to 0) can be added, reducing the need for repetitive code.
  • 📌 An assignment is given at the end, asking viewers to create more instructors with name and address attributes, and print their information.

Q & A

  • What is the purpose of the `__init__` method in Python classes?

    -The `__init__` method in Python is a special function that acts as a constructor. Its primary purpose is to initialize the attributes of a class when an object is created.

  • Why is the `self` keyword used in class methods?

    -The `self` keyword is used to refer to the current instance of the class. It allows the method to access and modify the object's attributes and ensures the method operates on the correct object.

  • How do you assign attributes to an object of a class?

    -Attributes can be assigned directly to an object using dot notation, like `object.attribute = value`. Alternatively, attributes can be initialized inside the `__init__` method by assigning values to `self.attribute`.

  • What happens if you don't pass any parameters to the `__init__` method?

    -If no parameters are passed to the `__init__` method, and it expects them, Python will raise a `TypeError`, stating that required positional arguments are missing.

  • What is the advantage of setting default values for parameters in the `__init__` method?

    -Setting default values for parameters allows you to create objects without providing values for those parameters. This is useful when certain attributes are optional or have a standard default value.

  • Can you modify the attributes of an object after it has been created?

    -Yes, attributes of an object can be modified after its creation using dot notation, such as `object.attribute = new_value`.

  • What is the difference between a class attribute and an instance attribute?

    -An instance attribute is specific to each object of a class and is set using `self.attribute`, while a class attribute is shared across all instances of the class.

  • What does the error 'missing required positional argument' indicate?

    -This error occurs when a function or method, like `__init__`, is called without providing the necessary arguments it expects, leading to an incomplete call.

  • Why is using a class beneficial for managing multiple similar objects?

    -Using a class allows for better organization and reusability of code, as it provides a blueprint for creating multiple objects with similar attributes and methods, reducing repetition and potential errors.

  • How would you create a new object with attributes in a Python class?

    -To create a new object with attributes, define the class with an `__init__` method that initializes the attributes. Then, create an object by calling the class and passing the necessary parameters to the `__init__` method.

Outlines

00:00

📚 Introduction to Object-Oriented Programming in Python

The speaker introduces the topic of Object-Oriented Programming (OOP) in Python, building on concepts discussed in previous videos such as classes and objects. They mention that the current video will focus on adding attributes and methods to classes, particularly the `__init__` method (Constructor) and the `self` keyword. The speaker also highlights the importance of constructors for initializing object attributes, which will be demonstrated in this video.

05:02

💻 Overview of a Python Programming Competition

The speaker briefly shifts focus to announce a Python programming competition called Ultra Combat, hosted by Anacademy. It offers up to 90% scholarships and various rewards such as MacBooks and smartphones. The competition, geared toward GATE and ESE aspirants, consists of 40 MCQs to be answered within 120 minutes. Participants can register for free using a provided code, and the event is scheduled for July 23 at 11 AM. The speaker encourages viewers to check the description box for further details and relevant links.

10:02

🧑‍🏫 Explaining Class Attributes in Python

Returning to the Python topic, the speaker explains how to add attributes to a class, using an example of an 'Instructor' class with attributes like `name` and `address`. The speaker demonstrates that attributes are specific to objects, and to access these, you must reference the object (e.g., `instructor1.name`). They show how assigning attributes directly to an object can lead to inconsistent and inefficient code, especially when handling multiple instructors. This highlights the need for a constructor (`__init__` method) to automate the process of initializing object attributes.

15:02

🔧 Introducing Constructors and the `__init__` Method

The speaker introduces the concept of constructors in Python using the `__init__` method, which automates the initialization of object attributes when an object is created. They clarify how `self` binds attributes to the current object and demonstrate the syntax of defining attributes such as `name` and `address` within the constructor. By automating attribute initialization, constructors help streamline object creation and reduce code repetition, making it easier to manage large numbers of objects.

📝 Example of Using Constructors to Simplify Code

The speaker walks through an example where the `__init__` method is used to create two instructor objects, passing attributes like `name` and `address` directly at object creation. They highlight how omitting required parameters results in errors and explain the role of `self` in binding values to the correct object. The example demonstrates how constructors simplify the code by eliminating the need to manually assign each attribute to every object.

🛠️ Using Default Values for Attributes in Python

The speaker explains how default values can be set for optional attributes like `Instagram followers`, which not all instructors may have. By setting a default value (e.g., `followers = 0`), the speaker shows how Python allows flexibility in creating objects without specifying every single attribute. This feature saves time and code, as default values can be overridden when necessary, but they prevent repetitive zero assignments for attributes not applicable to all objects.

💡 Assignment and Upcoming Lesson on Adding Methods

As the video wraps up, the speaker assigns viewers the task of creating two more instructor objects and printing their `name` and `address` attributes. The speaker teases the next video, which will cover adding methods to classes, building on the concept of attributes by focusing on what the objects can do, not just what they are. The video concludes with a thank-you message and an invitation to continue learning in the next installment.

Mindmap

Keywords

💡Object-Oriented Programming (OOP)

Object-Oriented Programming (OOP) is a programming paradigm where code is organized into 'objects' that contain both data and functions. In the video, the instructor explains how Python uses OOP concepts like classes, objects, and methods to structure programs in a more organized and reusable way.

💡Class

A class is a blueprint for creating objects in OOP. It defines a set of attributes and methods that the objects created from the class will have. In the video, the instructor discusses how to create a class and explains that it’s a user-defined data type, which allows developers to structure their code around real-world entities.

💡Object

An object is an instance of a class, meaning it is created from the class blueprint and can have its own unique data. The video demonstrates how objects are created from classes and how they hold attributes like name and address. Each object is a separate entity with its own values for these attributes.

💡Attributes

Attributes are variables that belong to an object or a class. They define the properties or characteristics of an object. In the video, the instructor shows how to add attributes like 'name' and 'address' to an object and discusses how these attributes are tied to specific objects, helping to store important information.

💡__init__ Method (Constructor)

The __init__ method is a special method in Python classes used to initialize the attributes of an object when it is created. The video explains that this method allows developers to assign values like 'name' and 'address' to an object automatically when the object is instantiated, streamlining the object creation process.

💡Self Keyword

The self keyword in Python is used within a class to refer to the current instance of the object. It allows methods and attributes to be accessed and modified for the specific object being referenced. In the video, the instructor explains that 'self' helps bind the attributes and methods to the object being created or modified.

💡Methods

Methods are functions that are defined inside a class and describe the behaviors or actions of an object. The video focuses on how methods will be discussed in a later lecture, differentiating them from attributes, which describe the object’s properties.

💡Default Values

Default values in function arguments allow a parameter to take on a predefined value if no argument is provided during function or method calls. The video demonstrates this with the example of 'Instagram followers', where a default value of 0 is set, reducing the need for manually passing '0' every time an instructor doesn’t have followers.

💡Gate and ESE Combat

Gate and ESE Combat is a competitive scholarship exam mentioned in the video, offering up to 90% scholarships and rewards like laptops and mobile phones. The exam is designed for students preparing for engineering entrance exams like GATE, covering subjects such as General Aptitude and Technical topics.

💡User-defined Data Type

A user-defined data type is a data type that is defined by the user in a program, rather than a pre-existing data type in the language. In the video, the instructor describes how a class functions as a user-defined data type, providing a structure for creating objects with specific attributes and behaviors.

Highlights

Introduction to object-oriented programming in Python and recap of previous concepts like classes and objects.

Discussion on adding attributes and methods to a class, focusing on how to initialize objects.

Explanation of the `__init__` method and its importance in initializing object attributes when creating an object.

Introduction of the `self` keyword and its role in referencing the actual object that is calling the method.

Demonstration of how to create object-specific attributes using `self` and initializing them within the `__init__` method.

The concept of a constructor in Python is explained as the `__init__` method that runs automatically upon object creation.

Explanation of how to pass arguments like name and address while creating an object to initialize its attributes.

Detailed walkthrough of assigning attributes to individual objects and how it reduces redundancy in the code.

Illustration of the problem of assigning attributes manually for multiple objects and how the constructor solves it.

The `__init__` method is demonstrated by passing custom attributes such as name and address to multiple instructor objects.

Example of handling default values for attributes, such as Instagram followers, where not all objects require a specific value.

Using default values in constructors to simplify object creation when some attributes are optional or have common values.

Demonstration of printing object-specific attributes like name and address for multiple instructor objects.

Assignment to create additional instructors and practice initializing and printing their attributes, reinforcing the concepts.

Teaser for the next video, which will cover adding methods to classes, further enhancing the functionality of object-oriented programming.

Transcripts

play00:00

hey everyone I hope you all are safe and

play00:02

doing good so in the series of learning

play00:03

Python programming language we are

play00:04

discussing object-oriented programming

play00:06

in python in the previous video we have

play00:08

seen like what is in class what is an

play00:10

object how to create a class how to

play00:12

create an object why do we need classes

play00:14

this thing we have discussed right

play00:17

but we haven't like we have created our

play00:20

own class but we haven't added any

play00:23

attributes or methods in that class so

play00:27

that thing we'll be discussing in this

play00:28

video

play00:29

how to add attributes what is that init

play00:32

method underscore underscore N8

play00:34

underscore underscore and in bracket a

play00:37

self keyword is passed as a parameter

play00:39

right so what is that method what is

play00:41

basically the fund of Constructor

play00:43

right how to initialize objects while

play00:46

creating those objects of a class so

play00:49

these things will be discussing in this

play00:50

video right but before that this one

play00:53

will tell you something it is especially

play00:54

important for gate and ASE as parents an

play00:58

academy is back with combat and this

play01:00

time it is ultra combat Yes you heard it

play01:02

right now you have a chance to get up to

play01:05

90 scholarship and many rewards such as

play01:09

MacBook Dell laptop Samsung Mobile and

play01:13

many more and this Ultra combat for gate

play01:16

and escs parents would be on would be

play01:19

conducted on 23rd of July and the timing

play01:22

is 11 am

play01:24

and what how many question you will get

play01:26

the pattern is 40 mcqs you will get and

play01:29

the time limit would be 120 Minutes

play01:31

right and what is the syllabus the

play01:34

syllabus will be General aptitude

play01:37

engineering mathematics and Technical

play01:39

and the most important thing is you can

play01:42

enroll for this Ultra combat for free

play01:44

you don't need to pay anything no

play01:46

registration fee nothing no charges

play01:48

right so the link for you know

play01:51

registration to enroll in this Ultra

play01:53

combat would be in the description box

play01:54

of this video for all the branches

play01:56

mechanical civil CS electrical right and

play01:59

you can use my code jkl10 to enroll for

play02:02

free in this combat right so all the

play02:04

relevant links and information you will

play02:06

find in the description box of this

play02:08

video you can go and check out okay now

play02:10

let's see this was the class we have

play02:12

created in the previous lecture the

play02:14

class instructor and we have done

play02:16

nothing here no attribute nothing else

play02:18

just pass and we have created one object

play02:20

and if you find out the type of this

play02:23

object then it will give you instructor

play02:25

right just forget about this and

play02:27

response for main underscore that also

play02:29

will I'll tell you in later videos so

play02:31

the classes this instructor so class

play02:34

means basically it's a user defined data

play02:36

type

play02:36

that it has a blueprint to create object

play02:39

okay now how to add attributes see if in

play02:44

instructor obviously the instructor is

play02:46

having some name or ID or information

play02:47

the main information so one way is

play02:51

instructor one

play02:54

instructor one

play02:55

dot name I am assigning like maybe

play03:00

pile

play03:01

right you cannot simply write down here

play03:04

just name is equal to Pi

play03:06

that would be simple a variable but now

play03:09

this name is an attribute of this

play03:11

instructor

play03:12

this instructor is an object that is why

play03:14

we are writing instructor dot name this

play03:17

name is now attached with this

play03:18

instructor with this object right so

play03:21

that is why this is now attribute one

play03:23

more thing if you want to check like

play03:25

instructor

play03:27

Dot

play03:28

address is equal to

play03:32

Delhi

play03:34

right and if you want to fetch if you

play03:36

want to print this information then how

play03:38

you can press simply we cannot write

play03:39

down like print name

play03:41

let's run this and what see what you

play03:43

will get

play03:44

name is not defined

play03:47

because name is

play03:50

its name is what instructor one dot name

play03:53

it's not just simply name a variable no

play03:56

it's now an attribute of this object so

play03:58

you must write here instructor 1 dot

play04:02

name this is the syntax right if you

play04:05

assign value to an object like this and

play04:07

if you want to fetch the value so

play04:08

instructor one dot name this time it

play04:10

will give pi

play04:11

right

play04:12

like this if like I have a YouTube

play04:14

channel I want to hire now 10 instructor

play04:16

to teach different different subjects

play04:19

and like the attribute of this

play04:22

instructor these instructor would be

play04:23

many attribute I want to store like name

play04:25

address and like maybe ID and phone

play04:30

number has camera has laptop has books

play04:34

these are simple attributes

play04:36

so for one instructor I want to store

play04:37

every information so same you can

play04:40

instructor one note name this instructor

play04:41

OneNote address instructor one dot ID

play04:43

instructor one dot phone number

play04:44

instructor one dot has camera and like

play04:46

this you can write down these lines

play04:48

and like this if I want to create one

play04:52

more instructor

play04:53

so in that case what will happen

play04:56

instructor 2 is equal to this same

play04:59

method now instructor two dot name and

play05:01

instructor two dot address and if I want

play05:04

to print instructor two dot name that is

play05:06

also fine it will print pile and

play05:09

okay there is some error here

play05:17

like this so it will give let's just

play05:20

rename this otherwise it will give same

play05:23

name so like Jenny

play05:25

so it will give pile and jelly

play05:27

like two name like this if you want to

play05:30

store information of 10 instructor then

play05:33

definitely it

play05:34

is not easy because we are it's so

play05:37

hectic so many number of lines

play05:39

right and maybe like name here I'm

play05:42

writing name here I'm writing username

play05:44

over here I'm writing address or simply

play05:46

instructor address maybe I can write

play05:48

here instructor address

play05:50

so the name of these attributes

play05:52

would be maybe different

play05:54

for each object for each object for each

play05:57

instructor right so it would be not easy

play05:59

to manage the information like this

play06:02

right and definitely now what is the use

play06:04

of class if we are writing this kind of

play06:06

thing that we can do with the help of

play06:09

simple variables we can create different

play06:11

variables for each instructor of each

play06:13

thing right

play06:14

now for this

play06:17

okay now class comes into picture

play06:20

now here

play06:22

we have for this thing we use the you

play06:25

can say the concept of Constructor if

play06:27

you are from C plus background if then

play06:30

you must have heard about Constructor

play06:31

right if not it's okay I'll tell you

play06:34

here

play06:35

so basically the task of an Constructor

play06:38

is to initialize

play06:40

the data members to assign values to the

play06:43

data members of a class

play06:45

when

play06:47

an object is created

play06:49

so Constructor will basically allow us

play06:52

to specify what would happen when we

play06:54

create this object when we create an

play06:57

object what would happen

play06:58

with the help of Constructor we can do

play07:00

this thing we can initialize

play07:03

the attributes the members of the class

play07:05

while creating we don't have to write

play07:07

down like instructor one dot name one

play07:09

dot address and we have to initialize

play07:10

separately no

play07:12

right so here we have a special function

play07:19

that is Def

play07:20

and

play07:22

this

play07:23

init function so see it is not just a

play07:26

simple function

play07:27

because it is special one because it is

play07:29

having underscore underscore init

play07:31

underscore underscore then in bracket

play07:32

also we have like cell it's

play07:34

automatically I haven't written C cell

play07:37

for like this

play07:38

if you write down this thing simply i n

play07:41

i then see you will got this thing self

play07:44

it's predefined predefined right so it's

play07:48

a special method

play07:50

and python interpreter no it is a

play07:53

special method and what it will do

play07:54

python intermittent python interpreter

play07:57

no knows about this method very well

play07:59

right

play08:01

now self is a key word why we are

play08:03

passing this self that also I'll tell

play08:05

you so in C plus plus we are having

play08:07

Constructor to initialize object in

play08:09

Python we are having this method init

play08:11

method to initialize the object

play08:14

to initialize the data members of a

play08:17

class while creating an object

play08:20

right

play08:21

so same as Constructor it is doing the

play08:24

same task

play08:25

okay now see

play08:27

and one more thing this init function

play08:29

would be called every time you create

play08:32

an object

play08:34

right so see if you want to check out

play08:37

this thing you can write down something

play08:38

like this print

play08:42

creating a new object I'm not writing

play08:44

anything I'm just printing here creating

play08:46

a new object and let's run this

play08:48

see first creating a new object because

play08:51

here

play08:53

we are

play08:55

creating an object so creating a new

play08:57

object then pile it will print file

play08:59

right then again creating a new object

play09:01

and Jenny it will print so two time

play09:03

this this would be printed so two time

play09:06

you have called this init function right

play09:08

this function has been called so this

play09:12

one object we have created another

play09:13

object we have created so every time you

play09:15

create an object of a class this init

play09:16

function would be called every time

play09:18

right and it is used to like initialize

play09:21

the attributes of that particular object

play09:24

right

play09:25

so the self is indicating it is

play09:29

referring the actual object on which

play09:31

right now we are calling this function

play09:33

on which this function has been called

play09:34

right now so if this function has been

play09:37

called right now on this object

play09:38

instructor 1 so the self is instructor

play09:41

one

play09:42

if next time this init function has been

play09:45

called during this line instructor 2 is

play09:48

equal to instructor so now at this point

play09:50

of time the selfish instructor 2 so it

play09:53

is referring to the actual object

play09:56

right so when we are calling this then

play09:59

it will initialize the instructor 1

play10:01

object attribute this time at this point

play10:06

of time it will initialize instructor to

play10:08

object attribute so I hope now you got

play10:10

why we are using this self keyboard here

play10:13

right if you are still not getting it's

play10:16

okay we'll do some practice here so I

play10:19

want to like

play10:22

pass name and address so like two

play10:25

parameter we can pass name

play10:28

and

play10:30

address any name you can take right

play10:33

and let's just remove the slime

play10:36

right

play10:37

now how to initialize the attribute of

play10:40

the instructor only two attribute I am

play10:42

taking name and address that's it so you

play10:44

have to write down the self keyword cell

play10:46

Dot

play10:48

the name of the attribute what you want

play10:50

the name of that review so I want name

play10:53

is equal to

play10:56

this is not compulsory that this name

play10:58

this parameter name and this should be

play11:01

same it may be different right so the

play11:04

self name is equal to whatever argument

play11:06

you will pass and that we will fetch

play11:08

here in this parameter name name so you

play11:11

have to write down here this name

play11:14

right see the color this name and this

play11:16

name is having same color but this name

play11:18

is having different color so here the

play11:20

attribute name you can take any things I

play11:22

can take here like

play11:24

instructor underscore name that is also

play11:27

fine

play11:28

Constructor and Square address but I am

play11:30

taking here name that's it

play11:34

so

play11:35

self dot second attribute name I am

play11:38

taking just address is equal to

play11:42

this address

play11:43

let's just take here

play11:51

let's

play11:52

rename this instructor underscore name

play11:54

the parameter name so here you need to

play11:56

pass

play11:57

instructor underscore name now you got

play12:00

the difference

play12:02

this parameter name and this name should

play12:04

be same and this attribute name you can

play12:06

take

play12:07

any name right it should not be

play12:10

same with this parameter name right

play12:13

okay now you don't need to assign the

play12:16

value initialize the object attribute

play12:19

like this what we can do just remove

play12:22

these two lines and

play12:24

while creating the object obviously this

play12:26

init function would be called so now it

play12:28

is expecting to pass these two parameter

play12:31

name and address so here only I can pass

play12:33

like Jenny and in address I am passing

play12:37

like

play12:39

Maybe gurgaon

play12:40

right

play12:42

and let's just comment out these lines

play12:45

for instructor 2 and let's just print

play12:46

instructor one dot name let's run this

play12:49

and it will print the name

play12:56

right so obviously it will reduce the

play12:59

number of lines of code right

play13:01

now for instructor to same

play13:05

so instructor 2 and instructor see now

play13:07

if I don't pass anything here and let's

play13:09

run this

play13:12

so you are getting an error

play13:14

see

play13:17

in line number 10 in line number 10 in

play13:20

this line in this line

play13:22

while you are creating this object then

play13:25

this init missing two required

play13:29

positional argument instructor name and

play13:31

address right

play13:32

so obviously this function would be

play13:34

called init method would be called while

play13:36

you are creating the object and you need

play13:37

to pass these two parameter not three

play13:40

maybe you think self is also there but

play13:43

self is just a keyword to bind the

play13:46

actual object

play13:48

with the values right so by default self

play13:51

at this time would be instructor 2 and

play13:53

by default self at this time would be

play13:56

instructor one so you don't need to pass

play13:58

the value for self it is just a keyword

play14:01

right so self is like basically just a

play14:05

keyword to bind

play14:07

it will bind the

play14:10

objects attributes to the argument

play14:13

received right

play14:16

obviously now you need to pass two

play14:18

argument here so I am passing like pile

play14:20

and address is like

play14:23

Delhi now this is fine you will not get

play14:26

any error now you can face this

play14:27

information right like this if you want

play14:29

to create 10 instructor then definitely

play14:31

now it would be easy and less number of

play14:34

less lines of code

play14:36

right

play14:37

so this is the use of the class and this

play14:39

init method I think it is clear to you

play14:42

guys what is this in it what is the self

play14:44

and all right now

play14:46

if you want to pass like by default

play14:49

let's take one example uh I want to pass

play14:52

the Instagram follower of each

play14:54

instructor maybe the instructor doesn't

play14:56

are not on Instagram right most of the

play14:59

teachers are not on Instagram so they

play15:00

are having zero zero zero followers

play15:02

right so that information is not

play15:04

mandatory right obviously everyone is

play15:07

having name everyone is having some

play15:08

specific address so that for sure but

play15:11

it's not compulsive that everyone is on

play15:13

Instagram and having some follower

play15:14

account right so if I pass here this is

play15:18

the case if I pass here like

play15:22

Instagram underscore

play15:26

if I pass a parameter Instagram

play15:27

underscore follower so maybe Jenny is

play15:30

not like on Instagram so you need to

play15:32

pass here zero and for pile also maybe

play15:34

you need to pass zero so maybe 10

play15:36

instructor for every instructor the

play15:39

count is zero so why you are passing

play15:41

zero zero it's just a waste of you can

play15:45

save time

play15:46

and they're not no logic to pass zero

play15:48

zero zero so what we can what we can do

play15:50

rather than

play15:51

making this

play15:53

in compulsory argument to pass we can

play15:56

set default value of this parameter cell

play15:59

Dot

play16:02

followers is equal to 0.

play16:05

and now see it's not like that if I am

play16:08

on Instagram and I have some followers

play16:09

so right now every object will be having

play16:12

zero follower of this class all the

play16:15

objects right but we can modify this

play16:17

this attribute specifically for any

play16:20

object like for Jenny if I want to

play16:21

modify then I can modify that is also

play16:24

fine that also will see

play16:25

right but for now you have to be clear

play16:28

this thing like you can pass default

play16:31

value also for any attribute now for

play16:34

every if I want to print like print and

play16:38

instructor one dot

play16:40

followers

play16:41

now it will print a zero

play16:43

see Jenny and zero because by default

play16:47

the follower count for each object of

play16:50

this class would be zero because we have

play16:52

set a default value right

play16:55

now I hope you got the idea like how to

play16:57

add attributes how to initialize the

play17:00

attributes of an object what is the you

play17:02

know use of this init function what is

play17:05

this self keyword like this

play17:07

so now one assignment for you is okay

play17:09

this is the class and all now you have

play17:12

to create two more instructor right

play17:15

passing the name and address and you

play17:18

have to print the information name as

play17:20

well as address for each instructor for

play17:22

the two instructor right

play17:25

so now that's it for this video in the

play17:27

next video we'll see how to add methods

play17:30

these are just attributes we haven't

play17:32

added still methods what the instructor

play17:35

will do we have just added what he or

play17:37

she has not what he or she does right so

play17:41

that thing we'll see in the next video

play17:42

so thanks for the next video then bye

play17:43

thank you

Rate This

5.0 / 5 (0 votes)

Related Tags
Python OOPClassesAttributesConstructorProgrammingScholarshipsGate ExamCoding TutorialBeginner PythonEngineering