Welcome to today's tutorial, where we'll be learning the basics of iterating through a CSV file to create dictionaries and collect summary statistics. First, let's import the CSV module, which will assist us in reading in our CSV file. Using some iPython magic, let's set the floating point precision for printing to 2. Now let's read in our mpg.csv using csv.DictReader and convert it to a list of dictionaries. Let's look at the first three elements of our list. We can see that the dictionaries in the list have the column names of the CSV as keys, and data for each specific car are the values. The length of our list is 234, meaning we have a dictionary for each of the 234 cars in the CSV file. We can look at what the column names of the CSV are by using the key method. Suppose we want to find the average city MPG across all cars in our CSV file. We sum the city MPG entry across all the dictionaries in our list and divide by the length of the list. Because the type for all the values in our dictionary are strings, we need to convert to float to perform mathematical operations. Similarly, we can find the average highway MPG across all the cars in our CSV file. And it makes sense that the average highway fuel economy is higher than in the city. Now, let's look at a more complex example. Say we want to know what the average city MPG is grouped by the number of cylinders a car has. Creating a set of the values in the cylinder entry of the dictionaries will give us the unique levels for a number of cylinders. We see that we have cars in out dataset with 4, 5, 6, and 8 cylinders. First, we'll create an empty list where we'll store our calculations. Next, let's iterate over all the cylinder levels. And then we'll iterate over all the dictionaries. If the cylinder level for the dictionary we're on matches the cylinder level we're calculating the average for, we add the mpg to our summpg variable and increment the count. After going through all the dictionaries, we perform the average MPG calculation and append it to our list. To make things clearer, I'm going to sort the list from lowest number of cylinders to highest. And we can see that the city fuel economy appears to be decreasing as the number of cylinders increases. Let's look at one more similar example. Suppose we're interested in finding the average highway MPG for the different vehicle classes. Looking at the different vehicle classes, we have 2seater, compact, midsize, minivan, pickup, subcompact, and SUV. Similar to the last example, we iterate over all the vehicle classes, then iterate over all the dictionaries. If the vehicle class for the dictionary matches the vehicle class we're computing the average highway MPG for, we add the value to our total, and increment the count. Then we perform the average calculation and append it to our list. This time, let's sort our list from lowest MPG to highest. Looks like the pickup had the worst fuel economy and the compact had the best. So that was a look into how to summarize data through iteration. Don't worry if this seems somewhat inefficient or tedious. Next week, we will be learning about Pandas, a Python library that allows for easier, more efficient, and more powerful data analysis in Python. Thanks for watching. Hope to see you again soon.