Exercise

Arrays and NumPy

NumPy is a scientific computing package in Python that helps you to work with arrays. Let's use array operations to calculate price to earning ratios of the S&P 100 stocks.

The S&P 100 data is available as the lists: prices (stock prices per share) and earnings (earnings per share).

Instructions

100 XP
  • Import the numpy as np.
  • Convert the prices and earnings lists to arrays, prices_array and earnings_array, respectively.
  • Calculate the price to earnings ratio as pe.