hackerank array indexing The Problem description is as follows Write the function array_index which accepts three numbers n,n_row,n_col and performs the array operations given below
import numpy as np
def array_index(n, n_row, n_col):
x = np.arange(n).reshape(n_row, n_col)
print(x[n_col])
if __name__ == '__main__':
n = int(input())
n_row = int(input())
n_col = int(input())
array_index(n, n_row, n_col)
Can someone help me complete the solution for this problem PS: Attached the image of the question for the reference enter image description here
import numpy as np
x=np.arange(n).reshape(n_row,n_col)
print(x[-1])
y=int(n_col/2)
print(x[:,y])
print(x[0:2,-3:])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.