CHAPTER 7

MUTABLE AND IMMUTABLE OBJECTS

CHAPTER OUTLINE

7.1 Lists

7.2 Sets

7.3 Tuples

7.4 Dictionary

Elementary forms of data such as numeric and Boolean are called scalar data types. Several applications require more complex forms of data, for example, the name of a person, coordinates of a point, a set of objects, or a list of personal records of individuals. In the previous chapter, we discussed about strings (type str – an immutable structure). In this chapter, we will discuss some other mutable and immutable objects, namely, lists, tuples, sets, and dictionaries.

7.1 LISTS

A list is an ordered sequence of values. It is a non-scalar type. Values stored in a list can be of any type such as string, integer, float, or list, for example, a list ...

Get Python Programming: A modular approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.