Python Practice › NumPy Programs › Program 16

Even integers from 1 to 20

EasyNumPy Programs · 16 of 100

Write a NumPy program to create an array of even integers from 1 to 20.

Advertisement
Output
[ 2  4  6  8 10 12 14 16 18 20]

Approach

  1. np.arange(2, 21, 2).

Solution

Python
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.

More numpy programs

← All 100 NumPy Programs

Leave a Comment