logo

Python의 numpy.zeros()

그만큼 numpy.zeros() 함수는 주어진 모양과 유형의 새로운 배열을 0으로 반환합니다. 통사론:

numpy.zeros(shape, dtype = None, order = 'C')>

매개변수:



  shape :   integer or sequence of integers   order :   C_contiguous or F_contiguous  C-contiguous order in memory(last index varies the fastest)  C order means that operating row-rise on the array will be slightly quicker  FORTRAN-contiguous order in memory (first index varies the fastest).  F order means that column-wise operations will be faster.    dtype :   [optional, float(byDeafult)] Data type of returned array.>

반품 :

ndarray of zeros having given shape, order and datatype.>

코드 1:

파이썬



소프트웨어 개발 수명주기




Eclipse의 javafx



# Python Program illustrating> # numpy.zeros method> > import> numpy as geek> > b>=> geek.zeros(>2>, dtype>=> int>)> print>(>'Matrix b : '>, b)> > a>=> geek.zeros([>2>,>2>], dtype>=> int>)> print>(>' Matrix a : '>, a)> > c>=> geek.zeros([>3>,>3>])> print>(>' Matrix c : '>, c)>

>

>

출력 :

스타 패턴 인쇄
Matrix b :   [0 0] Matrix a :   [[0 0]  [0 0]] Matrix c :   [[ 0. 0. 0.]  [ 0. 0. 0.]  [ 0. 0. 0.]]>

코드 2: 데이터 유형 조작

파이썬

int를 문자열 java로 변환하는 방법




# Python Program illustrating> # numpy.zeros method> > import> numpy as geek> > # manipulation with data-types> b>=> geek.zeros((>2>,), dtype>=>[(>'x'>,>'float'>), (>'y'>,>'int'>)])> print>(b)>

>

전가산기 진리표
>

출력 :

[(0.0, 0) (0.0, 0)]>

메모 : 0은 0 및 비어 있는 것과 달리 배열 값을 각각 0 또는 임의의 값으로 설정하지 않습니다. 또한 이러한 코드는 온라인 IDE에서 실행되지 않습니다. 작업을 탐색하려면 시스템에서 실행하십시오.