class of "hill climbingalgorithmsthat is we only keep the result if it is better than the previous one object-oriented programming in pythondefining classes we stated earlier that python is an object-oriented programming language so farwe have used number of built-in classes to show examples of data and control structures one of the most powerful features in an object-oriented programming language is the ability to allow programmer (problem solverto create new classes that model data that is needed to solve the problem remember that we use abstract data types to provide the logical description of what data object looks like (its stateand what it can do (its methodsby building class that implements an abstract data typea programmer can take advantage of the abstraction process and at the same time provide the details necessary to actually use the abstraction in program whenever we want to implement an abstract data typewe will do so with new class fraction class very common example to show the details of implementing user-defined class is to construct class to implement the abstract data type fraction we have already seen that python provides number of numeric classes for our use there are timeshoweverthat it would be most appropriate to be able to create data objects that "look likefractions fraction such as consists of two parts the top valueknown as the numeratorcan be any integer the bottom valuecalled the denominatorcan be any integer greater than (negative fractions have negative numeratoralthough it is possible to create floating point approximation for any fractionin this case we would like to represent the fraction as an exact value the operations for the fraction type will allow fraction data object to behave like any other numeric value we need to be able to addsubtractmultiplyand divide fractions we also want to be able to show fractions using the standard "slashformfor example in additionall fraction methods should return results in their lowest terms so that no matter what computation is performedwe always end up with the most common form in pythonwe define new class by providing name and set of method definitions that are syntactically similar to function definitions for this exampleclass fraction#the methods go here provides the framework for us to define the methods the first method that all classes should provide is the constructor the constructor defines the way in which data objects are created to create fraction objectwe will need to provide two pieces of datathe numerator and the denominator in pythonthe constructor method is always called __init__(two introduction