print ('The first element of X is: ', X[0])

print ('The first element of y is: ', y[0,0])

print ('The last element of y is: ', y[-1,0])

in the above code why x is given one index and y is given two indices

print ('The first element of X is: ', X[0])

print ('The first element of y is: ', y[0,0])

print ('The last element of y is: ', y[-1,0])

in the above code why x is given one index and y is given two indices

X is size (m, n), where ‘n’ is the number of features. If you print using only one index, you get an output that includes all values for the 2nd index.

If you print the shape of y, you’ see that it is (m, 1).

So technically it’s a 2D matrix, where the 2nd index is always 0.

So it can be addressed as either [0] or [0,0].

Probably just using y[0] would be more appropriate for this assignment.