Classes and Objects in python | how to create class and syntax in python |


Classes and Objects in python | how to create class and syntax  in python | 

Classes and Objects


Python is an object oriented programming language.
In OOP(object oriented programming) everything is an object . 
Object it has properties and method .
Class can also contain user define datatype but also contain function in it so class is basically called “Blueprint” for an object .


Classes and Objects in python
Classes and Objects in python 


Python class :



Class refer to a group of homogeneous entities .each entities of class is called object.

class is collection of data member i.e(variables)  and member function(function).
the class body contains the declaration of data member and member  function.
the variable declare inside the class are called Data member and function are called member function. This function and variable are collectively called class member.

class is user define data type with a template that serve to define its properties .

class is model for creating object this means that properties and  of object are written in class i.e class contain variable (Data member) and method together .

 an object is fundamental concept of object oriented program (oop) but class provide an ability to define similar type of object .

Syntax of Creating class using class diagram:

Class Diagrams: 





                       
                             
                           
Example:- Class name  Car which has some basic data like name ,brand ,model ,date of manufacture etc. and some function like engine on ,apply brake ,accelerate and change gear etc.

For example Class diagram:



 Class is a logical entity that has some specific attributes and methods.
class is collection of variable and function and class can be defined as a collection of objects.

 For example: if you have an student class then it should contain an attribute and method, i.e. id, name, rollno, division , etc.
class is user define data types. 
 The name of class immediately follows the keyword class.  Followed by colon as follows-


Syntax for Creating Class -
Class  ClassName:   
        <statement-1>   
        .   
        .    
        <statement-N> 



For Example:-


class student:
         pass




Note- when class is empty then written pass keyword. 
















Post a Comment

Post a Comment (0)

Previous Post Next Post