lower(self words split(def number_of_words(self)return len(self wordsdef starts_with(selfs)return len([ for in self words if [:len( )]== ]def number_with_length(selfn)return len([ for in self words if len( )== ] 'this is test of the class analyzer analyzer(sprint(analyzer wordsprint'number of words'analyzer number_of_words()print'number of words starting with " "'analyzer starts_with' ')print'number of -letter words'analyzer number_with_length( )['this''is'' ''test''of''the''class'number of words number of words starting with " " number of -letter words few notes about this programone reason why we would wrap this code up in class is we can then use it variety of different programs it is also good just for organizing things if all our program is doing is just analyzing some stringsthen there' not too much of point of writing classbut if this were to be part of larger programthen using class provides nice way to separate the analyzer code from the rest of the code it also means that if we were to change the internals of the analyzer classthe rest of the program would not be affected as long as the interfacethe way the rest of the program interacts with the classdoes not change alsothe analyzer class can be imported as-is in other programs the following line accesses class variableprint(analyzer wordsyou can also change class variables this is not always good thing in some cases this is convenientbut you have to be careful with it indiscriminate use of class variables goes against the idea of encapsulation and can lead to programming errors that are hard to fix some other object-oriented programming languages have notion of public and private variablespublic variables being those that anyone can access and changeand private variables being only accessible to methods within the class in python all variables are publicand it is up to the programmer to be responsible with them there is convention where you name those variables that you want to be private with starting underscorelike _var this serves to let others know that this variable is internal to the class and shouldn' be touched