pip setoutline(self backgroundpip draw(self winreturn pip def setvalue(selfvalue)""set this die to display value ""turn all the pips off for pip in self pipspip setfill(self backgroundturn the appropriate pips back on for in self ontable[value]self pips[isetfill(self foregroundthis example also showcases the advantages of encapsulation that talked about in we have significantly improved the implementation of the dieview classbut we have not changed the set of methods that it supports we can substitute this improved version into any program that uses dieview without having to modify any of the other code the encapsulation of objects allows us to build complex software systems as set of "pluggable modules case studypython calculator the reworked dieview class shows how lists can be used effectively as instance variables of objects interestinglyour pips list and ontable list contain circles and listsrespectivelywhich are themselves objects by nesting and combining collections and objects we can devise elegant ways of storing data in our programs we can even go one step further and view program itself as collection of data structures (collections and objectsand set of algorithms that operate on those data structures nowif program contains data and operationsone natural way to organize the program is to treat the entire application itself as an object calculator as an object as an examplewe'll develop program that implements simple python calculator our calculator will have buttons for the ten digits ( - ) decimal point )four operations (+-*/)and few special keys"cto clear the display"<-to backspace over characters in the displayand "=to do the calculation we'll take very simple approach to performing calculations as buttons are clickedthe corresponding characters will show up in the displayallowing the user to create formula when the "=key is pressedthe formula will be evaluated and the resulting value shown in the display figure shows snapshot of the calculator in action basicallywe can divide the functioning of the calculator into two partscreating the interface and interacting with the user the user interface in this case consists of display widget and bunch