Answer to Question #314310 in Python for xxx

Question #314310

4.Convert a 1-D array into a 2-D array

a = np.array(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'])


Answer:


Output:

array([['a', 'b', 'c'],

    ['d', 'e', 'f'],

    ['g', 'h', 'i'],

    ['j', 'k', 'l']], dtype='<U1')


5.Add 101 to all the values in given array

a = np.arange(16).reshape(4,-1)


Answer:


Output:

array([[101, 102, 103, 104],

    [105, 106, 107, 108],

    [109, 110, 111, 112],

    [113, 114, 115, 116]])


6.Extract the last 5 columns of this 2-D array

a = np.arange(100).reshape(5,-1)


Answer:


Output:

array([[15, 16, 17, 18, 19],

    [35, 36, 37, 38, 39],

    [55, 56, 57, 58, 59],

    [75, 76, 77, 78, 79],

    [95, 96, 97, 98, 99]])


1
Expert's answer
2022-03-20T14:41:08-0400

4.

a = np.array(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'])
a.reshape((4,-1))


5.

a = np.arange(16).reshape(4,-1)
a + 101


6.

a = np.arange(100).reshape(5,-1)
a[:,-5:]

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS