Problem

7/12

Zero array elements

Theory Click to read/hide

Zero array elements
 
Function nonzero(V) 
The result is a tuple of arrays. Each such array corresponds to a separate axis of the original array and contains indices with non-zero elements in this array.
V - a NumPy array or array-like object.
Returns a Python tuple (tuple) - tuple with arrays of indexes of non-zero elements of the original array V.
 
Function count_nonzero(V) 
This function is based on the built-in  __bool__() method of Python objects that checks whether they are true. It follows that the  count_nonzero() function is actually able to work not only with numbers, but also with any objects that can be either true or false.
V - a NumPy array or array-like object.
The function returns the number of non-zero array elements along the specified axis.

Problem

Given a vector Z

1) Write to the variable NonZerros indices of non-zero elements.
2) Write the  variable Count_NonZerros number of non-zero elements.

Add only 2 lines to the program. You don't need to input or output anything. The vector Z has already been created.