Python Lists and Dictionaries - GitHub Pages

嚜燕ython Lists and Dictionaries

CS 8: Introduction to Computer Science, Winter 2019

Lecture #13

Ziad Matni, Ph.D.

Dept. of Computer Science, UCSB

Administrative

?

Hw07 out today 每 DUE ON MONDAY 3/11

?

Lab07 每 will be issued for Tuesday

每 Due by next week Monday by 11:59 PM

每 A little involved, so feel free to pair-up (optional)

?

You are still working on Project #1#

?

MIDTERM #2 is graded!





3/4/19

right?

Will be put up on GauchoSpace by tomorrow

To review your midterms: same arrangement as with Midterm #1

Matni, CS8, Wi19

2

3/4/19

Matni, CS8, Wi19

3

Lecture Outline

? Doing more with Lists

每 Simple Example: Find the Median of multiple numbers

? Dictionaries

3/4/19

Matni, CS8, Wi19

4

What Operations Can We do with LISTS?

?

Find min, max, sum

每 max(list), min(list), sum(list)

每 How does this work with numbers? strings?

?

Add item to a list (at the end)

每 list.append(item)

?

Sort a list

?

每 list.count(item)

每 list.sort()

?

Reverse a list

?

Remove item from a list

每 list.remove(item)

3/4/19

Add item to a list (anywhere: before some index)

每 list.insert(index, item)

每 list.reverse()

?

Count how many of something

?

Remove LAST item from a list

每 list.pop()

Matni, CS8, Wi19

5

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

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

Google Online Preview   Download