ABSTRACT

This chapter is about tuples and sets in Python. A tuple is a finite ordered list of values of possibly different types which is used to bundle related values together without having to create a specific type to hold them. A tuple is defined as a data structure that comprises an ordered, finite sequence of immutable, heterogeneous elements that are of fixed sizes. Tuples are immutable. Once a tuple is created, you cannot change its values. A tuple is defined by putting a comma-separated list of values inside parentheses ( ). Each value inside a tuple is called an item. In this chapter, the authors discuss the zip() function, indexing of tuples, packing and unpacking, and so on.