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

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  memory issue loading movie to numpy array djf123 1 51 Nov-07-2019, 06:19 AM
Last Post: ThomasL
  Numpy structured array Nitram 3 225 Sep-17-2019, 10:09 PM
Last Post: jefsummers
  numpy.copy / numpy.delete paul18fr 3 273 Jul-26-2019, 01:51 PM
Last Post: paul18fr
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 4,284 May-29-2019, 02:48 AM
Last Post: heiner55
  Array in numpy Truman 5 4,131 May-26-2019, 10:14 AM
Last Post: snippsat
  [split] Array in numpy aapurdel 1 284 May-25-2019, 08:05 PM
Last Post: buran
  [numpy]add a value to an array elmismo999 1 370 May-23-2019, 04:15 PM
Last Post: michalmonday
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 410 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  while creating a array using numpy.arrange, how to negate only the last 50 numbers? vicky53 1 409 Apr-06-2019, 11:52 AM
Last Post: scidam
  creating an empty NumPy array in Python sandeepatel 2 1,101 Jan-16-2019, 09:24 AM
Last Post: rinu

Forum Jump:

Users browsing this thread: 1 Guest(s)