In Python, object-oriented technology Python is an object-oriented programming language that naturally provides object-oriented programming methods. However, it is very difficult to define an object-oriented programming method. The key to the problem is to understand the meaning of the object. Objects have a wide range of meanings. They are the abstraction, simulation, and refinement of the real world and the concept world. Object methods are similar to functions, but there are two differences: 1. methods are defined inside the class and are part of the class. The relationship between them is obvious; 2-The call syntax is different. [python] >>> class Time :... pass...> def printTime (time ):... print str (time. hours)...> now = Time (); >>> now. hours = 10; >>>> printTime (now) 10 >>>>>> class Time :... pass...> def printTime (time ):... print str (time. hours)...> now = Time (); >>> now. hours = 10; >>> printTime (now) 10 >>> we can change the function scope by changing the indentation. Attribution: [python] >>> class Time :... def printTime (self ):... print str (self. hours )...... def increment (self, hours ):... self. hours = hours + self. hours... while self. hours> = 12 :... self. hours = self. hours-12... self. day = self. day + 1... class Time :... def printTime (self ):... print str (self. hours )...... def increment (self, hours ):... self. hours = hours + self. hours... whi Le self. hours> = 12 :... self. hours = self. hours-12... self. day = self. day + 1 ......> optional parameters we have seen some built-in functions. The number of accepted parameters is variable. Similarly, you can define variable parameter functions. The following function calculates the sum of all the numbers from the number head to the tail and the step size. [Python] >>> def total (head, tail, step ):... temp = 0 ;... while head <= tail :... temp = temp + head ;... head = head + step ;...... return temp; ...... >>> total (1,100) Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: total () takes exactly 3 arguments (2 given) >>> total (1,100, 3) 1717 >>>> def total (head, tail, step = 2 ):... temp = 0 ;... while head <= tail :... temp = temp + head ;... head = head + step ;...... return temp; ...... >>> total (1,100); 2500 >>>> total (1,100, 3); 1717 >>>>> def total (head, tail, step ):... temp = 0 ;... while head <= tail :... temp = temp + head ;... head = head + step ;...... return temp; ...... >>> total (1,100) Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: total () takes exactly 3 arguments (2 given) >>> total (1,100, 3) 1717 >>>> def total (head, tail, step = 2 ):... temp = 0 ;... while head <= tail :... temp = temp + head ;... head = head + step ;...... return temp; ...... >>> total (1,100); 2500 >>> total (1,100, 3); 1717 >>>