declare numpy array of size in python code example
Example 1: python declare array of size n
>>> n = 5
>>> list = [None] * n
>>> print(list)
[None, None, None, None, None]
>>> list.append(1)
>>> list = list[-n:]
>>> print(list)
[None, None, None, None, 1]
>>> list.append(1)
>>> list = list[-n:]
>>> print(list)
[None, None, None, 1, 1]
>>> list.append(1)
>>> list = list[-n:]
>>> print(list)
[None, None, 1, 1, 1]
Example 2: dimensions of np array python
>>> x = np.zeros((3, 5, 2), dtype=np.complex128)
>>> x.size
30
>>> np.prod(x.shape)
30