Daily Data Science Puzzle
import numpy as np
# popular instagram accounts
# (millions followers)
inst = [232, #"@instagram"
inst = np.array(inst)
superstars = inst > 100
What is the output of this puzzle?
Numpy is a popular Python library for data science focusing on linear algebra.
The following handy numpy feature will prove useful throughout your career. You can use comparison operators directly on numpy arrays. The result is an equally-sized numpy array with boolean values. Each boolean indicates whether the comparison evaluates to True for the respective value in the original array.
The puzzle creates a list of integers. Each integer represents the number of followers of popular Instagram accounts (in millions). First, we convert this list to a numpy array. Then, we determine for each account whether it has more than 100 million followers.
We print the first and the third boolean value of the resulting numpy array. The result is True for @instagram with 232 million followers and False for @victoriassecret with 59 million followers.
Are you a master coder?
Test your skills now!