| As i said in my PHP post Object oriented programming knowledge is mandatory for fast and better development , as a python developer one should enhance his/her skill to build the OOP concept in python , implementing OOP is very easy in python . I am sharing some of my Object Oriented codes here , Example -1 [*] Program Description :- Here i created here a number Checker class with under this class the constructor of python __init__() is defined using this constructor i am passing two variable values and assigning this values to the Number1 and Number2 variable using self the self variable represents the instance of the object itself , then passing this variable to the Biggest number finder method namely findBiggest [*] class numberChecker: def __init__(self,number1 , number2): self.Number1 = number1 self.Number2 = number2 def findBiggest(self): if (self.Number1 > self.Number2): print "Biggest Number is "+str(self.Number1) else: print "Biggest Number is "+str(self.Number2) Here is the output #Now creating instance of the class >>>number = numberChecker(10,20) >>> print number <__main__.numberChecker instance at 0x01FF0850> >>> number.findBiggest() Biggest Number is 20 # The output Example - 2 [*]Program description :- here i created class name studentData which store the name,age , dept , and marks of the student . now according to the marks the o/p of the program shows the grade of the student [*] class studentData: def __init__(self,name,age,dept,marks): self.Name = name self.Age = age self.Dept = dept self.Marks = marks def getDetails(self): print "Details i have" print self.Name print self.Age print self.Dept print self.Marks def grade (self): if (self.Marks >=50 and self.Marks <=59): print "Student Name"+str(self.Name)+"has passed" if (self.Marks >=60 and self.Marks <=69): print "Student Name "+str(self.Name)+"Obtained Grade D" if (self.Marks >=70 and self.Marks <=79): print "Student Name"+str(self.Name)+"Obtained Grade C" if (self.Marks>=80 and self.Marks <=89): print "Student Name"+str(self.Name)+"Obtained Grade B" if (self.Marks>=90 and self.Marks <=100): print "Student Name"+str(self.Name)+"Obtained Grade A" else: print "Wrong Input" Here is the Output >>> student = studentData("Dipayan",25,"CS",80) >>> student.getDetails() Details i have Dipayan 25 CS 80 >>> student.grade() Student NameDipayanObtained Grade B #creating another instance using student name james >>> studentJames = studentData("james" ,25 ,"physics","A") >>> studentJames.grade() Wrong Input >>> studentJames = studentData("james" ,25 ,"physics",110) >>> studentJames.grade() Wrong Input >>> studentJames = studentData("james" ,25 ,"physics",100) >>> studentJames.grade() Student NamejamesObtained Grade A |