Classes and Objects
Learn about the classes and objects in Python.
We'll cover the following
In Python, every type is a class. Therefore int
, float
, complex
, bool
, str
, list
, tuple
, set
, and dict
are all classes. These are ready-made classes. Python also allows us to create user-defined classes as we’ll see in the next chapters.
An object is created from a class. A class describes two things: the form an object created from it will take, and the methods (functions) used to access and manipulate the object.
Multiple objects can be created from one class. When an object is created from a class, it can be understood that an instance of the class is being created.
A class has a name, whereas objects are nameless. Since objects do not have names, they are referred to using their addresses in memory.
All the above statements can be verified through the following program:
Get hands-on with 1400+ tech skills courses.