CS 111 Exam part 2

By "CS 111 Exam", I mean the exams that Scott is giving in his courses to help students identify their weaknesses and strengthen their skills.

The second part of the exam is intended to cover, very roughly, the material from the latter half of CS 111. Since the exam is cumulative, it will necessarily include topics from the first half of CS 111.

Here is a four-page PDF reviewing CS 111 topics

Exam Topics

For the second part of Scott's exam, I suggest you brush up on topics such as:

I can tell you with certainty that there will be a recursion problem, probably using nested arrays and/or dictionaries.

CSV files

Some of you took versions of CS 111 that skipped CSV files. Here are some review materials to get you up to speed on CSV files:

A few key pieces of information:

Here is program that uses the CSV module. It iterates over the lines from the file, and prints lines where the "kind" of phone is "home". It skips the header line.

import csv

with open('phone-list.csv') as file:
    phone_reader = csv.reader(file)
    for row in phone_reader:
        name, kind, phnum = row
        # skip the header row, which just has headers
        if name == 'name':
            continue
        if kind == 'home':
            print(f'call {phnum} for {name}')

The phone-list.csv file looks like this:

name,kind,phnum
Mom,home,7035555681
Mom,cell,7035551234
Connie,home,6095551243
Dad,home,7045553004
Dad,cell,7045551324
Dad,other,7045551343
Lynn,cell,6915551423
Pattie,home,6175551432
Allen,home,6175552134
Jeff,work,7815552314
Pat,work,7815552341
Matt Damon,work,6175552341
Scout,cell,8085553124
Ron,home,2075551111
Fred,cell,2035552222
George,work,4015553333
George,home,4015554444
Harry,home,8025558888
Percy,cell,4015559999

The output looks like:

call 7035555681 for Mom
call 6095551243 for Connie
call 7045553004 for Dad
call 6175551432 for Pattie
call 6175552134 for Allen
call 2075551111 for Ron
call 4015554444 for George
call 8025558888 for Harry

JSON

JSON is a notation for standard data structures. It allows us to turn a data structure into a string and a string into a data structure.