What is the output of this puzzle?
import numpy as np # salary in ($1000) [2015, 2016, 2017] dataScientist = [133, 132, 137] productManager = [127, 140, 145] designer = [118, 118, 127] softwareEngineer = [129, 131, 137] a = np.array([dataScientist, productManager, designer, softwareEngineer]) print(a.shape) print(a.shape)
Numpy is a popular Python library for data science. The focus of the library is computations on arrays, vectors, and matrices. If you work with data, there is no way that you can avoid numpy. So learn it now and learn it well.
We work on salary data of four jobs: data scientists, product managers, designers, and software engineers. We create four lists that store the yearly average salary of the four jobs in thousand dollars for three subsequent years.
Then, we merge these four lists into a two-dimensional array (denoted as matrix), i.e., a list of lists. Each salary list of a single job becomes a row of this matrix. Each row has three columns, one for each year.
The puzzle prints the shape of this matrix which is the number of elements in each dimension. For example, a matrix with n rows and m columns has shape (n,m). As our two-dimensional matrix has 4 rows and 3 columns, the solution of this puzzle is 4 and 3.
Are you a master coder?
Test your skills now!