Important Notice:

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

Slicing in 1 Dimensional Array:-

Syntax:- arr_name[start:end:step]

arr_name[star_index:end_index+1]

arr_name[start_index:]

arr_name[:end_index+1]

arr_name[:]

Note:-Indexing can be positive as well Negative.

import numpy as np

a=[]

size=int(input(“Enter size”))

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])

arr1=arr[2:4]

print(arr1)

 

#Slicing in 1D array

import numpy as np

a=np.array([10,20,30,40,50,60,70,80,90])

print(a)

print(a[4:])

print(a[:4])

print(a[4:7])

print(a[:-1])

print(a[::-1])

print(a[-4::])

print(a[-2::-2])

print(a[::])

 

 

error: Content is protected !!