May-08-2018, 05:01 PM

Hi there, I don't understand the answer to this task:

This is the task:

import numpy as np

# Subway ridership for 5 stations on 10 different days

ridership = np.array([

[ 0, 0, 2, 5, 0],

[1478, 3877, 3674, 2328, 2539],

[1613, 4088, 3991, 6461, 2691],

[1560, 3392, 3826, 4787, 2613],

[1608, 4802, 3932, 4477, 2705],

[1576, 3933, 3909, 4979, 2685],

[ 95, 229, 255, 496, 201],

[ 2, 0, 1, 27, 0],

[1438, 3785, 3589, 4174, 2215],

[1342, 4043, 4009, 4665, 3033]

if True:

print ridership[1:3, 3:5]

Answer:

[[2328 2539]

[6461 2691]]

But why?

If we have [1:3] that means Row: 1 column 3 --> The answer should be: 2328 and not [2328 2539]

If we have [3:5] that means Row: 3 column 5 --> No answer....

Can somebody explain me, the new python user , why the answer is correct? Or maybe send me a link to the video tutorial/blog what ever.....

Thank you!

J

This is the task:

import numpy as np

# Subway ridership for 5 stations on 10 different days

ridership = np.array([

[ 0, 0, 2, 5, 0],

[1478, 3877, 3674, 2328, 2539],

[1613, 4088, 3991, 6461, 2691],

[1560, 3392, 3826, 4787, 2613],

[1608, 4802, 3932, 4477, 2705],

[1576, 3933, 3909, 4979, 2685],

[ 95, 229, 255, 496, 201],

[ 2, 0, 1, 27, 0],

[1438, 3785, 3589, 4174, 2215],

[1342, 4043, 4009, 4665, 3033]

if True:

print ridership[1:3, 3:5]

Answer:

[[2328 2539]

[6461 2691]]

But why?

If we have [1:3] that means Row: 1 column 3 --> The answer should be: 2328 and not [2328 2539]

If we have [3:5] that means Row: 3 column 5 --> No answer....

Can somebody explain me, the new python user , why the answer is correct? Or maybe send me a link to the video tutorial/blog what ever.....

Thank you!

J