Get The Most Affordable Hosting in the World!
Starting at just $1.87/month, Vercaa offers unbeatable pricing for world-class web hosting services.
Fast, reliable, and secure hosting to power your website without breaking the bank. Plus, enjoy a free CDN for faster loading times worldwide!
Get Started Now!Python is a highly object-oriented language. In Python, each and every element in a Python program is an object of one or the other class. A number, string, list, dictionary etc. used in a program they are objects of corresponding built-in classes.
Example
When you execute this code, it will produce the following output −
<class 'int'> <class 'float'> <class 'str'> <class 'dict'> <class 'function'>
In Python, the Object class is the base or parent class for all the classes, built-in as well as user defined.
The class keyword is used to define a new class. The name of the class immediately follows the keyword class followed by a colon as follows −
-
The class has a documentation string, which can be accessed via ClassName.__doc__.
-
The class_suite consists of all the component statements defining class members, data attributes and functions.
Example
Any class in Python is a subclass of object class, hence object is written in parentheses. However, later versions of Python don't require object to be put in parentheses.
To define an object of this class, use the following syntax −