BYU logo Computer Science

To start this lab, download this zip file.

Lab 24 - Structured Data

Each activity will have you answer one or more questions about the provided JSON dataset.

IMPORTANT

Windows users should open their JSON files with the encoding='UTF-8' argument:

def read_json_file(json_file):
    with open(json_file, encoding='UTF-8') as file:
        return json.load(file)

Activities

pokemon.py

Write a function named longest_name that returns the full information for the pokemon with the longest English name.

nobel.py

Write a function named most_recipients which returns the year that had the most Nobel laureates across all categories?

Hint: count the number of laureates for each year; then find the year with the highest count.

Note: There are some years that don’t have any laureates.

Write a function named longest_name that returns the full name (firstname + ' ' + surname) of the laureate with the longest name.

Note: There are some laureates that do not have surnames. Ignore laureates that do not have

airlines.py NOT REQUIRED

Write a function named weather_delays that returns the airport, year combination that had the most delays due to weather.

Hint: use a tuple (airport, year) as the grouping key.

Write a function named security_delays that returns the year with the most minutes of security-related delays across all airports.

Write a function named greatest_ratio that returns the airport with the highest ratio of total flights to number of carriers.

Hint:

  • Group by airport to count total flights.
  • Then group by airport to get a list of carriers for each airport; don’t add a carrier to the list if it is already in the list. Split by comma to get individual carrier names.
  • Iterate over the keys (i.e. the airports) to find the airport with the highest ratio (total_flights / number_of_carriers)

Grading

ActivityPoints
pokemon.py6
nobel.py24
airlines.py0