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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.