Important Notice:

Course Content
NumPy Basic in Python (Chapter-13) M3-R5
About Lesson

#spliting example

import numpy as np

a=[1,2,3,4,5,6]

print(a)

a1,a2,a3=np.split(a,[3,4])

print(a1,a2,a3)

Output

[1, 2, 3, 4, 5, 6]

[1 2 3] [4] [5 6]

 

#creating 1D array

import numpy as np

a=[ ]

size=int(input(“Enter how many number “))

for i in range(size):

    val=int(input(“enter value “))

    a.append(val)

arr=np.array(a)

for i in range(arr.size):

    print(arr[i])

print(type(arr))

 

#indexing 1D Array

import numpy as np

a=np.array([10,20,30,40,50])

print(a[0])

print(a[1])

print(a[-1])

print(a[-3])

Output:

10

20

50

30

 

 

error: Content is protected !!