def processbutton(selfkey)updates the display of the calculator for press of this key text self display gettext(if key =' 'self display settext(""elif key ='<-'backspaceslice off the last character self display settext(text[:- ]elif key ='='evaluate the expresssion and display the result the try except mechanism "catcheserrors in the formula being evaluated tryresult eval(textexceptresult 'errorself display settext(str(result)elsenormal key pressappend it to the end of the display self display settext(text+keydef run(self)infinite 'event loopto process button clicks while truekey self getbutton(self processbutton(keythis runs the program if __name__ ='__main__'first create calculator object thecalc calculator(now call the calculator' run method thecalc run(notice especially the very end of the program to run the applicationwe create an instance of the calculator class and then call its run method non-sequential collections python provides another built-in data type for collectionscalled dictionary while dictionaries are incredibly usefulthey are not as common in other languages as lists (arraysthe example programs in the rest of the book will not use dictionariesso you can skip the rest of this section if