Jay’s Son

Jed Rembold

April 8, 2026

Is it only Wednesday?

Quick Announcements

  • Expect Midterm 2 results back on Monday
  • I’m still trying to find a moment to send out new grade reports
  • Enigma is live!
    • You essentially have two weeks for this one. Use the time wisely!
    • Sections today and tomorrow are meant to get you started!

Daily LO’s

  • How should we think about choosing data types for complicated data?
  • What is JSON useful for?
  • How can we load and export JSON files?
  • How can we work with deeply nested data?

Group Problems

Problem 1: Selecting from Nested Data

Suppose I had created the data structure to the right in order to keep track of class sizes over the years. How would I access the size of my Spring 2018 Mechanics (Phys 339) class?

  1. data[2018]['classes']['Phys339']
  2. data[1]['Phys339']
  3. data[1]['classes']['Phys339']
  4. data[2018]['Phys339']
data = [
    {   'year': 2017,
        'semester': 'Fall',
        'classes': {
            'Phys221': 38,
            'Phys110': 49
        }
    },
    {   'year': 2018,
        'semester': 'Spring',
        'classes': {
            'Phys339': 16,
            'Phys222': 35
        }
    },
    {   'year': 2018,
        'semester': 'Fall',
        'classes': {
            'CS151': 26,
            'Phys110': 45
        }
    }
]

Problem 2a: Reading in JSON

  • This is a coding problem. Work in pairs or trios on a single computer, and discuss your algorithm/approach before you write any code!
  • The file sanderson.json is a JSON file containing information on books written by Brandon Sanderson.
  • Read this file into Python and use it to determine how many books are represented in the data.

Problem 2b: Specific Books

  • Swap who is typing!
  • Use the data structure you read in earlier to determine:
    • What is the title of the earliest published book?
    • How many books have subtitles?
    • Which book has the most editions published?

Problem 2c: Aggregates

  • Swap who is typing!
  • Now use your data structure to determine the following:
    • How many unique languages have these books been translated to?
    • Who is Sanderson’s most common co-author?

Problem 2d: Purely Sanderson

  • Swap who is typing!
  • Suppose you really wanted to data set of only those books where Sanderson was the only author.
  • Edit your data set to remove all book entries with any author that is not Brandon Sanderson.
  • Write the modified data set to a new JSON file called pure_sanderson.json

D&Demo!

Spell Data

  • I’ve gone and grabbed all 300+ D&D spells into a single data structure, where each spell has a similar internal structure
  • Let’s use that structure to write some code to do the following:
    • Print out all spells from a chosen school below a certain level threshold
    • Print out all spells from a chosen class that have no verbal component
    • Determine which spell does the most cold damage at level 11
// reveal.js plugins // Font Awesome Characters