Javatpoint Logo
Javatpoint Logo

11. Python program to print the number of elements present in an array

In this program, we need to count and print the number of elements present in the array.

Some elements present in the array can be found by calculating the length of the array.

Python program to print the number of elements present in an array

Length of above array is 5. Hence, the number of elements present in the array is 5.

ALGORITHM:

  • STEP 1: Declare and initialize an array.
  • STEP 2: Calculate the length of the array that is a number of elements present in the array.
  • STEP 3: An in-built function can calculate length.
  • STEP 4: Finally, print the length of the array.

Array in Python is declared as

Arrayname = [ele1, ele2, ele3,....]
len() method returns the length of the array in Python.


PROGRAM:

Output:

Number of elements present in given array: 5
Next TopicPython Programs





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA