Python Practice › NumPy Programs › Program 18
Integers 1 to 100 in steps of 6
Write a NumPy program to create an array of integers from 1 to 100 with a difference of 6.
Output
[ 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97]
Approach
np.arange(1, 101, 6).
Solution
import numpy as npprint(np.arange(1, 101, 6))Output
[ 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97]
Learn the concept
New to this topic? Read the lesson, then come back.