Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to get the size of a numpy array?
#1
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=', ')
Quote
#2
np.size(nparray)
Quote
#3
“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" !
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 617 May-29-2019, 02:48 AM
Last Post: heiner55
  Array in numpy Truman 5 3,008 May-26-2019, 10:14 AM
Last Post: snippsat
  [split] Array in numpy aapurdel 1 103 May-25-2019, 08:05 PM
Last Post: buran
  [numpy]add a value to an array elmismo999 1 141 May-23-2019, 04:15 PM
Last Post: michalmonday
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 191 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 195 Apr-06-2019, 11:52 AM
Last Post: scidam
  counting the occurence of a specified number in a numpy-matrix PhysChem 1 175 Apr-03-2019, 01:37 PM
Last Post: PhysChem
  How convert multidimensional array to two dimensional array tkkhan44 1 275 Feb-20-2019, 05:00 AM
Last Post: scidam
  Numpy Quick start Tutorial leodavinci1990 1 358 Feb-03-2019, 07:10 AM
Last Post: buran
  creating an empty NumPy array in Python sandeepatel 2 466 Jan-16-2019, 09:24 AM
Last Post: rinu

Forum Jump:


Users browsing this thread: 1 Guest(s)