Is This an Average Puzzle? Yes!

Daily Data Science Puzzle

import numpy as np

# Goals in five matches
goals_brazil = np.array(
    [1,2,3,1,2])
goals_germany = np.array(
    [1,0,1,2,0])

br = np.average(goals_brazil)
ge = np.average(goals_germany)
print(br>ge)

What is the output of this puzzle?
*Beginner Level*

Numpy is a popular Python library for data science focusing on arrays, vectors, and matrices.

This puzzle introduces one new feature of the numpy library: the average function. When applied to a 1D numpy array, this function returns the average value of the numpy array.

In the puzzle, the average of the goals of the last five games of Brazil is 1.8 and of Germany is 0.8. On average, Brazil shot one more goal per game.


Are you a master coder?
Test your skills now!

Related Video

Solution

True

 

Leave a Comment

Your email address will not be published. Required fields are marked *