Top travel cities
Introduction to lists
As we already know from living in the digital age, programming is a powerful tool for answering questions about data. It allows us to collect, clean up and format our data and then perform calculations on that data. Much of the digital information we encounter is in the form of text. We ask questions with text and get answers in text. Maybe you have had someone ask you what your top 10 favorite restaurants were? How about cars, or motorcycles? The answer you give to this question is in text, and the best way for you to format your answer is in the form of a list. These top 10 lists are all organized in an ordered list of text items.
In this module we will explore how Python can help us to organize a list and help us to access different components of the list using different criteria. We will explore the characterictics of the list data type using a list of top travel cities from the popular magazine Travel and Leisure. After we have explored the list data type, we will put our new found knowledge into practice and map out these top cities on a map.
Objectives of this module
- Review Python data types
- Understand the list data type
- Assign a list to a variable
- Iterate through a list
- Use the index of the items in a list
- Add to a list
- Remove items from a list
- Change items in a list
- Select items in a list individually and as a group
- Compare items in a list
- Plot list items on a map visualization
We will be getting a good look at the list data type in this module, but first, we will take a brief look into the data types that can make up a list.