Exercise

Accessing safely and deleting

Alphabet Inc. was formed in 2015 as part of a corporate restructuring of Google. Analyzing the change in stock prices over time is a common task in the world of finance. One way to store stock data is to use the dates as keys and the prices as values in a dictionary. In this exercise, you access stock closing price data for the company Alphabet for various dates without knowing beforehand if each date has data available. The supplied dictionary alphabet_hist has datetimes as keys and stock closing prices as values. A datetime object named closing_price_date is supplied.

Instructions 1/3

undefined XP
    1
    2
    3
  • Access the closing price for the day before in a way that is safe, even if that date is missing.