Python Practice › NumPy Programs › Program 18

Integers 1 to 100 in steps of 6

EasyNumPy Programs · 18 of 100

Write a NumPy program to create an array of integers from 1 to 100 with a difference of 6.

Advertisement
Output
[ 1  7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97]

Approach

  1. np.arange(1, 101, 6).

Solution

Python
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]
Advertisement

Learn the concept

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

More numpy programs

← All 100 NumPy Programs