Python Practice › NumPy Programs › Program 12

Create an array from values

EasyNumPy Programs · 12 of 100

Write a NumPy program to create an array with the values 10, 34, 86, 26, 56.

Advertisement
Output
[10 34 86 26 56] int64

Approach

  1. np.array(list).

Solution

Python
import numpy as nparr = np.array([10, 34, 86, 26, 56])print(arr, arr.dtype)
Output
[10 34 86 26 56] int64
Advertisement

Learn the concept

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

More numpy programs

← All 100 NumPy Programs