In this python numpy program, we will test whether a number is scalar or not using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create an array using np.array().
- Test whether a number is scalar or not using np.isscalar().
- Print the output.
import numpy as np
x = 8.9
print(np.isscalar(x))
y = [8.9]
print(np.isscalar(y))
Output:
True
False