Читать книгу Introduction to Python Programming for Business and Social Science Applications - Frederick Kaefer - Страница 73
Introduction
ОглавлениеThis chapter develops a broader foundation of Python programming, covering compound data types, including lists, tuples, and dictionaries, as well as working with string methods and operations. You can use lists, which are indexable collections of objects, to store and access data of various types. We use lists to process data that include strings, numeric values, and Boolean values. We next learn about list methods and how methods are like functions but fundamentally different in their use. We then revisit string objects (introduced in Chapter 2), introducing commonly used string methods that are useful when working with text data. We also go into depth on string operations, which facilitate the manipulation of data that are either entered in by users or read from files and/or the Internet as is covered in later chapters. The next topic covered is tuples, which are like lists but have specific properties and purposes of their own. We then introduce dictionaries, which are key-value mappings that present powerful capabilities for working with data. We conclude the chapter with an example from the General Social Survey (GSS) that uses tuples and dictionaries to report the meaning of coded data. We will see throughout the textbook that these compound data types play a pivotal role in working with data.