Lists - Carnegie Mellon University

[Pages:32]Lists and Methods

15-110 ? Friday 09/24

Announcements

? Hw2 due Monday at noon ? Quiz1 went quite well! Median score was 86/100

? If you're not happy with your score, talk to your TA for tips on how to study for next time

2

Muddiest Point

? When do we use len(s)-1 vs. len(s) when working with strings?

? len(s)-1 is the last index of the string. Use s[len(s)-1] to get the last character.

? len(s) is the length of the string, and one beyond the last index. Slicing and range go up to and not including the endpoint, so use s[x:len(s)] to go from x to the end, and range(len(s)) to loop over all indexes.

3

Learning Goals

? Read and write code using 1D and 2D lists ? Use string/list methods to call functions directly on values

4

Unit 2 Overview

5

Unit 2: Data Structures and Efficiency

Data Structures: things we use while programming to organize multiple pieces of data in different ways.

Efficiency: the study of how to design algorithms that run quickly, by minimizing the number of actions taken.

These concepts are connected, as we often design data structures so that specific tasks have efficient algorithms.

6

Unit 2 Topic Breakdown

Data Structures: lists, dictionaries, trees, graphs Efficiency: search algorithms, Big-O, tractability

7

Lists

8

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download