object-oriented programming creating your own classes class is template for objects it contains the code for all the object' methods simple example here is simple example to demonstrate what class looks like it does not do anything interesting class exampledef __init__(selfab)self self def add(self)return self self example( print( add()to create classwe use the class statement class names usually start with capital most classes will have method called __init__ the underscores indicate that it is special kind of method it is called constructorand it is automatically called when someone creates new object from your class the constructor is usually used to set up the class' variables in the above programthe constructor takes two valuesa and band assigns the class variables and to those values the first argument to every method in your class is special variable called self every time your class refers to one of its variables or methodsit must precede them by self the purpose of self is to distinguish your class' variables and methods from other variables and functions in the program to create new object from the classyou call the class name along with any values that you want to send to the constructor you will usually want to assign it to variable name this is what the line =example( , does to use the object' methodsuse the dot operatoras in addmod( more practical example here is class called analyzer that performs some simple analysis on string there are methods to return how many words are in the stringhow many are of given lengthand how many start with given string from string import punctuation class analyzerdef __init__(selfs)for in punctuations replace( ''