Section 13.2 Objects Revisited
In Python, every value is actually an object. Lists, strings, and even integers are all objects. Programs manipulate those objects either by performing computation with them or by asking them to perform methods. To be more specific, we say that an object has a state and a collection of methods that it can perform. (More about methods below.) The state of an object represents those things that the object knows about itself. The state is stored in instance variables. For example, as we have seen with lists, each list has a state consisting of the list’s contents. All lists provide methods that allow us to modify the state:
append
, sort
, clear
and so on. Individual lists are different in that even though they are all lists, they each have different states (different contents).You have attempted of activities on this page.