Data Analysis with Python - Numpy Operations

Tell us what’s happening:

Describe your issue in detail here.
wrong answer for the challenge

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Data Analysis with Python - Numpy Operations

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Are you sure? check the value of a after the code execute

My bad. I misunderstood the question.

The question is

What is the value of a after you run the following code?

a = np.arange(5)
a + 20

since we know that in the first line a is created as array([0,1,2,3,4])
if we try to add 20 to this then it would be array([20,21,22,23,24])
the options are given as follows

[20, 21, 22, 24, 24]
[0, 1, 2, 3, 4]
[25, 26, 27, 28, 29]

and the correct answer it showing is [0,1,2,3,4] . How come it would be correct ?

Because a is not changed

1 Like