Python Practice › NumPy Programs › Program 25

All values except 1

EasyNumPy Programs · 25 of 100

Write a NumPy program to print all values of the vector 1-20 except 1.

Advertisement
Output
[ 2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20]

Approach

  1. v[1:].

Solution

Python
import numpy as npv = np.arange(1, 21)print(v[1:])
Output
[ 2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20]

Learn the concept

New to this topic? Read the lesson, then come back.

More numpy programs

← All 100 NumPy Programs

Leave a Comment