Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


Python is an object-oriented programming language and it allows to create objects. In order to create an object, first of all, object should be defined in the program. The Python class keyword is used to define a new object type. Within a class, object's methods and properties are defined and when an object is created, its methods and properties are determined by the class in which it is created.

Syntax

#defining new object type
class class_name:
      statements

#creating an object
MyObject = cleass_name()

Example:

In the below example, a class (new object type) called circle and object of this class called MyCircle are created. MyCircle has only one property radius which is defined in class circle. Please check the syntax for accessing object property inside program.

class circle:
  radius = 10

MyCircle = circle()
print(MyCircle.radius)

The output of the above code will be:

10

❮ Python Keywords