About Lesson
Accessing array using while loop:-
from array import * ar=array(‘i’,[10,20,30,40,50]) l=len(ar) i=0 while i<l: print(ar[i]) i=i+1 |
Dynamic initialization of Array:-
from array import * ar=array(‘i’,[]) n=int(input(“Enter array size : “)) for i in range(n): ar.append(int(input(“Enter Element: “))) for i in range(len(ar)): print(ar[i]) |
Reverse printing of array :-
from array import * ar=array(‘i’,[]) n=int(input(“Enter array size : “)) for i in range(n): ar.append(int(input(“Enter Element: “))) print(“Array elements are “) for i in range(len(ar)-1,-1,-1): print(ar[i],end=” “) |