Classes and Objects in Programming
Learn about the usage of classes and objects in Python.
We'll cover the following
In Python, every type is a class. So int
, float
, complex
, bool
, str
, list
, tuple
, set
, and dict
are all classes.
A class has a name, whereas objects are nameless. Since objects do not have names, they are referred to using their addresses in memory.
When we use the simple statement num = 10
, a nameless object of type int
is created in memory, and its address is stored in num
. Therefore, num
refers to or points to the nameless object that contains the value 10
.
However, instead of saying that num
refers to a nameless int
object, it is often said for the sake of convenience that num
is an int
object.
Let’s look at more programmatic examples of classes and objects:
Get hands-on with 1400+ tech skills courses.