L = [1,2,3,3]print(L[1:4])import numpy as npL = [[1,2,3],[6,7,8],[22,33,44]]N = np.array([[1,2,3],[6,7,8],[22,33,44]])print(N)print(N[:1,:1])print(N[1:2, :]) # return just the second row and all the columnsprint(N[:,:]) # print allprint(N[-1,-1]) # print the last element in tha numpy arrayprint(N[:1,:1])# return the first element in the row with the first element in the columnes L = ['first','second','third','fourth','fifth','sixth','seventh','eight','ninth','Ten'] print(L[:6]) # return all first six elements (To six)print(L[6:]) # return just sixth element exactly and all after (from six)print(L[-1]) # return last elementprint(L[-1:-3])print(L[-1:])print(L[-3:-1])print(L[1:9:3]) # [begin, end, step] jump equal to 3 print(L[::4])print(L[::-1]) # reverse the list print(L[::-2]) # just type the even number for example and reverse itarr = np.array([[1,2,3,4,5], [6,7,8,9,10]])print(arr)print(arr[1,1])print(arr[0,0])print(arr[:1, 1:4])print(arr[:1,:1])print(arr[1:,1:])# let's change the first element :arr[:1,:1]= 11 #change print(arr)arr[:] = 99 # change all values L = np.array([[1,2,3,4,5,6],[3,4,5,6,7,9],[45,33,22,77,66,98]])print(L)print(L[2:, 4:]) # we make two line to full understand , #first horizontal line for row wich is third line , second vertical for column which is 5 and the contact is the sol.L[1:, 4:] = 888print(L)
0 Comments:
Post a Comment