logo

Python의 numpy.arange()

그만큼 arange([start,] 중지[, step,][, dtype]) : 간격에 따라 균등한 간격의 요소가 포함된 배열을 반환합니다. 언급된 간격은 반만 열려 있습니다. 즉, [시작, 중지)

매개변수:



 start :  [optional] start of interval range. By default start = 0 stop :  end of interval range step :  [optional] step size of interval. By default step size = 1, For any output out, this is the distance between two adjacent values, out[i+1] - out[i]. dtype :  type of output array>

반품:

Array of evenly spaced values. Length of array being generated = Ceil((Stop - Start) / Step)>

예:

파이썬3








# Python Programming illustrating> # numpy.arange method> import> numpy as geek> print>(>'A '>, geek.arange(>4>).reshape(>2>,>2>),>' '>)> print>(>'A '>, geek.arange(>4>,>10>),>' '>)> print>(>'A '>, geek.arange(>4>,>20>,>3>),>' '>)>

힙과 힙 정렬
>

>

출력 :

A [[0 1] [2 3]] A [4 5 6 7 8 9] A [ 4 7 10 13 16 19]>

메모:

  • 이러한 NumPy-Python 프로그램은 onlineID에서 실행되지 않으므로 시스템에서 실행하여 탐색하세요.
  • 일반적인 내장 range() 함수에 비해 numpy.arange()의 장점은 정수가 아닌 일련의 숫자를 생성할 수 있다는 것입니다.

예:

파이썬3




MB에서 GB로
# Python Programming illustrating> # numpy.arange method> import> numpy as np> # Printing all numbers from 1 to> # 2 in steps of 0.1> print>(np.arange(>1>,>2>,>0.1>))>

>

>

산출:

[1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9]>

range() 함수로 시도하면 TypeError가 발생합니다.