#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Felix Muzny 10/11/2022 DS 2000 Lecture 10 - lists of lists Logistics: - HW 4 is due on *tonight* at 9pm -> no late submissions will be accepted - Quiz 5 is available on Gradescope (due Friday @ 9:50am) - Homework 5 is available on the course website (due *next* Friday 10/21 @ 9pm) - remote attendance (https://bit.ly/remote-ds2000-muzny) Three ways to participate (please do one of these!) 1) via the PollEverywhere website: https://pollev.com/muzny 2) via text: text "muzny" to the number 22333 to join the session 3) via Poll Everywhere app (available for iOS or Android) Warm-up 1 - functions 1 --- What is the value of x at the marked point in the following code? """ """ Warm-up 2 - functions 2 --- What is the value of x at the marked point in the following code? """ """ """ """ functions: syntax reminders --- (Deitel & Deitel 4.2) def function_name(parameters, separated, by, commas): # code return value # to call the function answer = function_name(values, matching, in, number) """ """ Slicing --- """ """ Lists of lists --- A list of lists is a "table" of data: neighborhood,latitude,longitude Charlestown,42.3787,-71.0593 Allston / Brighton,42.3596,-71.1466 Back Bay,42.3594,-71.0587 South Boston,42.3337,-71.0466 Dorchester,42.3594,-71.0587 South Boston,42.3332,-71.0481 Dorchester,42.3149,-71.093 South End,42.3428,-71.0783 Allston / Brighton,42.3583,-71.1275 """ # syntax examples """ Verify all rows same length --- Write a function, verify_tabular, that returns True if all rows in a list of lists have the same length and False otherwise. """ """ Lists of lists and nested loops (example 1) --- Write a function, sum_2d_list that sums all numbers in a 2-dimensional list of lists of numbers. Do this without using the python sum() function. """ """ Lists of lists and nested loops (example 2) --- Write a function, sum_2d_list that capitalizes all words in a 2-dimensional list of lists of strings. """ """ Example program - updating earnings.py --- Update earnings.py so that we only read the data in once, into a list of lists, then extract the target column from the list of lists rather than re-opening the underlying file each time. Add a search functionality to search for titles that contain some substring. (The data comes from here, originally: https://data.boston.gov/dataset/employee-earnings-report) """ """ Next time: - data: where does it come from? - more on scope - lists + mutation """