Class and objects in Python



Python is very versatile language it supports 3 types of programming paradigm which is a kind of perks of being an python user .
  • functional programming 
  • procedural programming
  • object oriented programing

so classes and objects fall under the category of object oriented programming, which is very useful when it comes to industry application

what is a class in python  ?

class can be defined " as the way of creating objects " , it means classes are the blocks of code which defines what an object be or what will be the work of that object .

class are the block of codes in which attributes (variables) and behaviour (methods) (functions) are defined . it is designing structure of object

 OBJECTS:
 
objects can be explained as a abstraction of data   from particular  class or objects are the entities or instances of class which perform actions based on what code is stored in their referring class.
objects represent a class



Example/ syntax


class michael:    # class michael is defined
   
      def con(self):    # fun named con is declared as self is mic which is an object
               print("hello")

mic = michael()         # object created for  class michael

michael.con(mic) or mic.con()       # calling function for function con



















 

Comments

  1. nice code bro... keep it up.. try to learn java programming too..
    [750gistmedia.com.ng]

    ReplyDelete

Post a Comment