in typical imperative python programs--including those that make use of classes and methods to hold their imperative code-- block of code generally consists of some outside loops (for or while)assignment of state variables within those loopsmodification of data structures like dictslistsand sets (or various other structureseither from the standard library or from third-party packages)and some branch statements (if/elif/else or try/except/finallyall of this is both natural and seems at first easy to reason about the problems often arisehoweverprecisely with those side effects that come with state variables and mutable data structuresthey often model our concepts from the physical world of containers fairly wellbut it is also difficult to reason accurately about what state data is in at given point in program one solution is to focus not on constructing data collection but rather on describing "whatthat data collection consists of when one simply thinks"here' some datawhat do need to do with it?rather than the mechanism of constructing the datamore direct reasoning is often possible the imperative flow control described in the last paragraph is much more about the "howthan the "whatand we can often shift the question encapsulation one obvious way of focusing more on "whatthan "howis simply to refactor codeand to put the data construction in more isolated place-- in function or method for exampleconsider an existing snippet of imperative code that looks like this