tailieunhanh - Ebook Starting out with python (2nd edition): Part 2

(BQ) Part 2 book "Starting out with python" has contents: Lists and tuples, more about strings, dictionaries and sets, dictionaries and sets, inheritance, recursion, GUI programming. | CHAPTER 8 Lists and Tuples TOPICS Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions Copying Lists Processing Lists Two-Dimensional Lists Tuples Sequences CONCEPT: A sequence is an object that holds multiple items of data, stored one after the other. You can perform operations on a sequence to examine and manipulate the items stored in it. A sequence is an object that contains multiple items of data. The items that are in a sequence are stored one after the other. Python provides various ways to perform operations on the items that are stored in a sequence. There are several different types of sequence objects in Python. In this chapter we will look at two of the fundamental sequence types: lists and tuples. Both lists and tuples are sequences that can hold various types of data. The difference between lists and tuples is simple: a list is mutable, which means that a program can change its contents, but a tuple is immutable, which means that once it is created, its contents cannot be changed. We will explore some of the operations that you may perform on these sequences, including ways to access and manipulate their contents. Introduction to Lists CONCEPT: A list is an object that contains multiple data items. Lists are mutable, which means that their contents can be changed during a program’s execution. Lists are dynamic data structures, meaning that items may be added to them or removed from them. You can use indexing, slicing, and various methods to work with lists in a program. 295 296 Chapter 8 Lists and Tuples A list is an object that contains multiple data items. Each item that is stored in a list is called an element. Here is a statement that creates a list of integers: even_numbers = [2, 4, 6, 8, 10] The items that are enclosed in brackets and separated by commas are the list elements. After this statement executes, .

TỪ KHÓA LIÊN QUAN