Skip to main content

Introduction to Python Class

Python is an object oriented programming language. Almost everything in Python is an object, with its properties and methods.

Class is like an object constructor, a "blueprint", or  an outline for creating a new object. An object is anything that can be manipulated  or changed  while working through the code. Every time a class object is instantiated, which means when we declare a variable, a new object is initiated from scratch.

Class objects can be used over and over again whenever needed. It is a prototype from which objects are created.

It creates a user-defined data structure, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. 

Like function definitions begin with the def keyword in Python, class definitions begin with a class keyword.

Class Definition Syntax:

class ClassName:
    # Statement-1
    #Statement-2
    .
    .
    #Statement-N

Example:

Class apple:
    pass

In the above example, the class keyword indicates that you are creating a class followed by the name of the class.

Tags
Submitted by devanshi.srivastava on July 13, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.