Is a value a scalar?

EasyNumPy Programs · 7 of 100

Write a NumPy program to test whether a value is a scalar.

Advertisement
Input
8.9, [8.9]
Output
True False

Approach

  1. np.isscalar().

Solution

Python
import numpy as npprint(np.isscalar(8.9), np.isscalar([8.9]))
Output
True False
Advertisement

Learn the concept

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

More numpy programs

← All 100 NumPy Programs