1 of 9

Lecture 5: Dictionary Methods & CSV Data

Autumn 2026

1

Sli.do

#cse163

Questions?

Icebreaker

Favorite street food?

CSE 163

CSE 163: Dictionary Methods & CSV Data

​

​

2 of 9

Announcements

  • Section 2 Check-in due tonight October 9 at 11:59pm on Gradescope
  • Programming Practice 1 due Sunday October 11 at 11:59pm on Gradescope
    • You can submit as many times before the deadline
    • Smaller programming practice problems on a similar level as in-class exercises
  • Complete this Intro Survey, due tonight, October 9th at 11:59pm
    • Last chance!
    • Will replace a missed lesson review.
  • Homework 1 will be graded these next few days, aiming to release first resubmission form sometime next week!
    • Use resubmission form if you didn’t submit during this first deadline
    • Use resubmission if you want a higher score

2

Questions?

CSE 163: Dictionary Methods & CSV Data

​

​

3 of 9

Today’s Roadmap

  1. Dictionary Methods
  2. Enumerate and Zip
  3. Processing CSVs
  4. Practice Problems!

3

CSE 163: Dictionary Methods & CSV Data

​

​

4 of 9

Recap: Dictionaries

  • Python has a data structure called dictionary that allows us to use immutable data as keys and mutable/immutable data as values
    • Keys are unique, but values do not have to be

4

d = {} # Empty dictionary

d['a'] = 1 # Create key ‘a’ with value 1

d['b'] = 2 # Create key ‘b’ with value 2

print(d) # {'a': 1, 'b': 2}

CSE 163: Dictionary Methods & CSV Data

​

​

5 of 9

Dictionary Methods

5

dict() or {}

Makes an empty dictionary

d[key]

Gets the value for k, KeyError if None

d[key] = val

Assigns val as the value for key

d.pop(key)

Removes key from this dictionary

d.keys()

Returns a collection of the keys

d.values()

Returns a collection of the values

d.items()

Returns a collection of (key, value) tuples

CSE 163: Dictionary Methods & CSV Data

​

​

6 of 9

Enumerate (loop over indices and values)

  • Enumerate is a method that allows you to loop over both the indices and elements of a sequence at the same time.

6

squares = [i ** 2 for i in range(1, 11)]

for i, n in enumerate(squares):

print(i, n) # Prints index (i) and value (n) of list

CSE 163: Dictionary Methods & CSV Data

​

​

7 of 9

Zip (loop over multiple sequences)

  • Zip allows you to loop over multiple sequences at the same time.

7

numbers = [i for i in range(1, 11)]

squares = [i ** 2 for i in numbers]

cubes = [i ** 3 for i in numbers]

for n, s, c in zip(numbers, squares, cubes):

print(n, s, c) # Prints values from each list

CSE 163: Dictionary Methods & CSV Data

​

​

8 of 9

Processing CSVs

8

Questions?

CSE 163: Dictionary Methods & CSV Data

​

​

9 of 9

Practice Problems!

9

Questions?

CSE 163: Dictionary Methods & CSV Data

​

​