Python Practice › NumPy Programs › Program 25
All values except 1
Write a NumPy program to print all values of the vector 1-20 except 1.
Output
[ 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
Approach
v[1:].
Solution
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.