derived classes provide for special needs let' turn to the savings accounts in factthey are specialized case of the account class we have just written nextwe are going to write class called savingsaccount which extends the account classor is derived from it this basically means that all functionality that is available in the account class is also available in the savingsaccount class we tell python that the savingsaccount class is based on the account class by starting the class definition with class savingsaccount(accountwe say that derived class/subclass is based on superclass/base class this means that anything that is available in the superclass is also available in the subclass class savingsaccount(account) ''class for objects representing savings accounts shows how class can be extended '' interest_rate methods def apply_interest(self) self balance *( +savingsaccount interest_ratein our main applicationwe instantiate two savings accounts if __name__=="__main__" annesacc savingsaccount( "anne" annesacc deposit( annesacc apply_interest( print(annesacc stefansacc savingsaccount( "stefan" stefansacc deposit( stefansacc apply_interest( print(stefansaccthe image on the next page shows the class hierarchy and the objects we instantiated from it note that although the instance attributes balancenumber and holder were set in the constructor of the account classthey are attributes of the instance objects we set them as self balancenot as account balance in the constructor method when we apply any instance method on an objectthe class hierarchy is searched from bottom to the top for instancewe did not define constructor method in the savingsaccount class because the savingsaccount class is based on the account classpython continues looking for an init method at the superclass (account)finds it there and executes this method when creating new object by calling the savingsaccount class annemarie friedrichcis lmu munchenws /