Python Language Notes Part-4
Types of Variables
In medieval in ops, we have two different types of variables.
The first one is instance variable, and the second one is class
variables. The value is initially set to 10 and beyond, but you
can change it.
Ivan 20 and less than three of the cities, Monty Python is the
city of Monty. Ivan said, "We know how to work with class and
object widen. If you have also seen how can you create a
variable inside an object, of course, right? Every object should
know something, but when it comes to medieval in operations,
we have a different type of variable."
Ivan 20 said, "Ivan 20 and Ivan 20 is Ivan 20. ...I'm Ivan 20,
Ivan 20." Ivan 20 continued, "I'll be Ivan 20 from Monty Python.
I'll show you how to learn how to use Monty Pythagnes. I'm a
Monty Pyro. I've got a new thing. I won't be afraid to learn
about how to create a new way of thinking about it. You'll be
able to use it again. You can use it. It's a new trick. It is a new
tool. It will be a new technique. It has a new skill. It can be a
tool."
Ivan 20 explained, "If you want to have a variable that will
change, it will affect all other objects. Variables that are
instance variables are different for different objects. If you
change one object, it will not affect other objects. However, if
you change a variable that is common for all the objects, it will
affect all objects. The number of wheels in a car is four by
default, but what if in the future, you got a new concept, and
they're saying, "Hey, now this time, we'll have five tires or five
wheels." In this case, what you will do is you will define a
variable outside in it and inside a class, of course, it becomes a
class variable. If we define the variable inside in it, it becomes
an instance variable. We can use object name alba and
classname, both works. So you are getting value for right.
What if you want to change the value of it? Run this particular
see, the value is changing now. Run that particular see,
running this particular run this specific see, the value is. Run
, the code now, and you can see we got the output we got 4 & 4
right, and you can see that. You can you say that the moment
you change the value of wheels, it will affect all the objects,
right, because they are shared."
In the next video, Ivan 20 will talk about different types of
methods, so stay tuned. Class variables are also called static
variables.
The output in the video is 5 and 5. That's your plus variable.
The point to remember is we have two level variables, instance
variables, and class variables, or in fact, class variable or class
variables also called static variables. In this video, we have a
class variable. For instance variables or instance variables, we
have two instance variables. The next episode will be about the
first episode of the series of episodes of this series of this
episode.
Inner class
Can a Class have another Class?
According to Ivan20, a class can have variables and methods.
In Python, we define functions to print values. But can we have
classes inside a class? Let's understand this by creating a
Laptop class inside the Student class.
A class can have a name of a person or a roll number.
We can't write readables and methods inside a class
We can create a Laptop class inside a Student class so
that we can get that group.
Here is an example code snippet:
class Student: class Laptop: def
__init__(self, brand, cpu): self.brand =
brand self.cpu = cpu def
show(self): print(self.brand, self.cpu)
def __init__(self, name, roll_number):
self.name = name self.roll_number =
Types of Variables
In medieval in ops, we have two different types of variables.
The first one is instance variable, and the second one is class
variables. The value is initially set to 10 and beyond, but you
can change it.
Ivan 20 and less than three of the cities, Monty Python is the
city of Monty. Ivan said, "We know how to work with class and
object widen. If you have also seen how can you create a
variable inside an object, of course, right? Every object should
know something, but when it comes to medieval in operations,
we have a different type of variable."
Ivan 20 said, "Ivan 20 and Ivan 20 is Ivan 20. ...I'm Ivan 20,
Ivan 20." Ivan 20 continued, "I'll be Ivan 20 from Monty Python.
I'll show you how to learn how to use Monty Pythagnes. I'm a
Monty Pyro. I've got a new thing. I won't be afraid to learn
about how to create a new way of thinking about it. You'll be
able to use it again. You can use it. It's a new trick. It is a new
tool. It will be a new technique. It has a new skill. It can be a
tool."
Ivan 20 explained, "If you want to have a variable that will
change, it will affect all other objects. Variables that are
instance variables are different for different objects. If you
change one object, it will not affect other objects. However, if
you change a variable that is common for all the objects, it will
affect all objects. The number of wheels in a car is four by
default, but what if in the future, you got a new concept, and
they're saying, "Hey, now this time, we'll have five tires or five
wheels." In this case, what you will do is you will define a
variable outside in it and inside a class, of course, it becomes a
class variable. If we define the variable inside in it, it becomes
an instance variable. We can use object name alba and
classname, both works. So you are getting value for right.
What if you want to change the value of it? Run this particular
see, the value is changing now. Run that particular see,
running this particular run this specific see, the value is. Run
, the code now, and you can see we got the output we got 4 & 4
right, and you can see that. You can you say that the moment
you change the value of wheels, it will affect all the objects,
right, because they are shared."
In the next video, Ivan 20 will talk about different types of
methods, so stay tuned. Class variables are also called static
variables.
The output in the video is 5 and 5. That's your plus variable.
The point to remember is we have two level variables, instance
variables, and class variables, or in fact, class variable or class
variables also called static variables. In this video, we have a
class variable. For instance variables or instance variables, we
have two instance variables. The next episode will be about the
first episode of the series of episodes of this series of this
episode.
Inner class
Can a Class have another Class?
According to Ivan20, a class can have variables and methods.
In Python, we define functions to print values. But can we have
classes inside a class? Let's understand this by creating a
Laptop class inside the Student class.
A class can have a name of a person or a roll number.
We can't write readables and methods inside a class
We can create a Laptop class inside a Student class so
that we can get that group.
Here is an example code snippet:
class Student: class Laptop: def
__init__(self, brand, cpu): self.brand =
brand self.cpu = cpu def
show(self): print(self.brand, self.cpu)
def __init__(self, name, roll_number):
self.name = name self.roll_number =