( / )*( ( + *hf( - * ))/( *hthe problem with this code isof coursethat all the constructors are identicalso we duplicate great deal of code although the duplication of this simple constructor might not be big problemit can easily lead to errors if we want to change the constructor laterand it is therefore worth avoiding as mentioned abovea general idea of oop is to place code common to many classes in superclass and to have that code be inherited by the subclasses in this casewe can make superclass containing the constructor and let the different subclasses implement their own version of the __call__ method the superclass will be very simple and not really useful on its ownclass diffdef __init__(selffh= - )self fself fh the subclasses for the first-order forward formula and the secondand fourthorder central difference formulas can then look like class forward (diff)def __call__(selfx)fh self fself return ( ( +hf( ))/ class central (diff)def __call__(self, )fh self fself return ( ( + )- ( - ))/( *hclass central (diff)def __call__(selfx)fh self fself return ( / )*( ( +hf( - )/( * ( / )*( ( + *hf( - * ))/( *hto use this simple class hierarchy in an examplesaywe want to compute the derivative of (xsin for with the fourth-order central difference formulafrom math import sinpi mycos central (sinmycos(piherethe line mycos central (sincreates an instance of the central class by calling the constructor inherited from the superclasswhile mycos(picalls the __call__ method implemented in the subclass as indicated by the (hn terms in the formulas abovethe methods have different levels of accuracy we can empirically investigate the accuracy of the numerical differentiation formulasusing the class hierarchy created above using (xsin xx / as an examplethe code can look like from diff import forward central central