Python - . , , , , - . , , , .
""
.
[], . . .
:
"" :
- Prime = ['string1', 'string2', 'string3']
- Prime[1] = 'string2'; //true
len() .
for. Pascal , , .
. [ for in ];
"" . :
- [[0 for j in range(m)] for i in range(n)]
NumPy
"" NumPy.
, . . , .
, "" - array(). ndarray.
array ndarray. array.type(). . - <class 'numpy.ndarray'>.
, dtype=np.complex .
- array2 = np.array([ /**/, dtype=np.complex)
, , zeros(). ones(). .
, 2 .
- array([
- [[0, 0]]
- [[0, 0]]]
- )
, print(). , NumPy .
, set_printoptions(). 1000 . threshold.
NumPy
"" .
, . , . :
- array1 = np.array([[1, 2, 3], [1, 2, 3]])
- array2 = np.array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])
array1 + array2 , - 2, - 3.
- array1 = np.array([1, 2, 5, 7])
- array2 = arange([1, 5, 1])
Array1 + array2 2, 4, 8, 11. , .
, ndarray sum().
- np.array(array1 + array1) == array1 + array2
ndarray . np. ( ).
"" . shape().
(2, 2, 3). , shape() . , - . reshape(). .
. , ravel() , . transpose() .
, . "" "" (). for.
"". [start:stop:step]. start , , stop - , - . start , , stop , - , . , .
, :
, mas[:]. [1, 2, 3, 4]. , -3, .
, . , mas[::2] [1, 3]. , , [::-2] , [3, 1].
. "" [:, 2] , . [:2] - .
, . Python , , . , np.arange(10) array2 = array1, , , array1 array2. . array1.shape(3, 4) array2.
- array1.shape() == (3, 4);//true
- array2.shape() == (3, 4);//true
view() . , array, view()
array2 , , . :
- array2 is array1; //false
, .
- array1.shape(2, 6)
- array1 == array2; // true
,
. . hstack() , vstack() - .
column_stack() . column_stack() row_stack(), , . , hsplit(), vsplit() - .