Python Practice › NumPy Programs › Program 16
Even integers from 1 to 20
Write a NumPy program to create an array of even integers from 1 to 20.
Output
[ 2 4 6 8 10 12 14 16 18 20]
Approach
np.arange(2, 21, 2).
Solution
import numpy as npprint(np.arange(2, 21, 2))Output
[ 2 4 6 8 10 12 14 16 18 20]
Learn the concept
New to this topic? Read the lesson, then come back.