Python Forum

Full Version: How to get the size of a numpy array?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am having some problems with this task.
I am supposed to use the command range to generate a list of 100 numbers
between 0 and 1 (both 0 and 1 should be included) and a list comprehension.

I have tried by using np.arange, but as a fairly new user, I am not sure if is the same
thing as range. I have tried to use 'range' before but it does not work with floats.
Since the numbers needed to be generated must be 100, I have tried to look for a specific
command that allows me to find out how many numbers are generated, but I haven't had any success.
Here is the code:

import numpy as np
from scipy import *
from numpy import array


for i in np.arange(0, 1.01, 0.0101):

    print(i, end=', ')
np.size(nparray)
“100 numbers between 0 and 1 (both 0 and 1 should be included)”

I observe that if evenly distributed there will be 101 numbers: 0, 0.01, 0.02, .... 0.99, 1