Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to get the size of a numpy array?
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=', ')
“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
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Life of Brian: Conjugate the verb, "to go" !

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  import numpy in sub-files paul18fr 1 110 Aug-06-2019, 12:38 PM
Last Post: chakrimakam
  Converting set of tuples to set of 2D numpy arrays ThemePark 0 89 Aug-04-2019, 05:07 PM
Last Post: ThemePark
  Trying to replace for loops with numpy vspoloni 8 403 Aug-04-2019, 07:09 AM
Last Post: paul18fr
  Add column to numpy matrix Gigux 1 129 Aug-02-2019, 12:05 AM
Last Post: scidam
  Python/C API Matrix to Numpy jibarra 0 95 Jul-29-2019, 03:25 PM
Last Post: jibarra
  numpy.copy / numpy.delete paul18fr 3 149 Jul-26-2019, 01:51 PM
Last Post: paul18fr
  Error installing numpy srm 3 323 Jul-08-2019, 06:26 PM
Last Post: srm
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 1,435 May-29-2019, 02:48 AM
Last Post: heiner55
  Array in numpy Truman 5 3,589 May-26-2019, 10:14 AM
Last Post: snippsat
  [split] Array in numpy aapurdel 1 198 May-25-2019, 08:05 PM
Last Post: buran

Forum Jump:

Users browsing this thread: 1 Guest(s)