Python Practice › NumPy Programs › Program 7
Is a value a scalar?
Write a NumPy program to test whether a value is a scalar.
Input
8.9, [8.9]
Output
True False
Approach
np.isscalar().
Solution
import numpy as npprint(np.isscalar(8.9), np.isscalar([8.9]))Output
True False
Learn the concept
New to this topic? Read the lesson, then come back.