Program to print the elements of an array present on even position in Python. This program contains array initialisation, print statement and for loop. This is useful for beginners, class 11, 12 and B Tech computer science students.
Program to print the elements of an array present on even position
What is an Array ?
An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together.
What is to be done in this program :
In this program, we need to print the element which is present on even position. Even positioned element can be found by traversing the array and incrementing the value of i by 2.

In the above array, elements on even position are b and d.
Source code :
arr = [1, 2, 3, 4, 5];
print("Elements of given array present on even position: ");
for i in range(1, len(arr), 2):
print(arr[i]);
Download Source code:
Explanation of source code :
step 1:Initialize array
arr = [1, 2, 3, 4, 5];
print(“Elements of given array present on even position: “);
step 2: Loop through the array by incrementing the value of i by 2
step 3:Here, i will start from 1 as first even positioned element is present at position 1.
for i in range(1, len(arr), 2):
print(arr[i]);
Output :
RESTART: C:/csstudy/source code file 2/Program to print the elements of an array present on even position in Python.py Elements of given array present on even position: 2 4 >>>
Output Explanation:
Elements of given array present on even position:
2
4
The elements at the even positions are calculated and printed out . The array is defined in the program itself. Array 1 =[1,2,3,4,5]
The even number is shown in the output .
Conclusion:
The program is running fine.
Thank you for reading, learning and downloading source code. This program contains array initialisation, print statement and for loop. This is useful for beginners, class 11, 12 and B Tech computer science students. for more programs like this , click below links
csstudy.in/category/python-programs/
Computer Science with Python Practical Book Solutions Class 11 Term -2 – CS Study
Computer Science Practical file for class 12 Term-2 – CS Study
Python Projects for Class 12 with Source Code (Mysql Connectivity) – CS Study