Question 8
Y = np.array([
[3,6,9,12],
[15,18,21,24],
[27,30,33,36],
[39,42,45,48],
[51,54,57,60]])
Answer:
Question 8 Output
array([[ 3, 12],
[27, 36],
[51, 60]])
import numpy as np
j = 0
list1 = []
Y = np.array([
[3,6,9,12],
[15,18,21,24],
[27,30,33,36],
[39,42,45,48],
[51,54,57,60]])
for i in Y:
if j % 2 == 0:
list1.append([i[0], i[-1]])
else:
pass
j = j + 1
print(np.array(list1))
[[ 3 12]
[27 36]
[51 60]]
Comments
Leave a comment