What's the use of python3?
This article mainly shows you "what is the use of python3", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the use of python3" this article?
Python3 custom algorithm sorting
Sorted (A1, key = functools.cmp_to_key (cmp))
A1 is to be sorted list,cmp is the sorting function
Numpy
T An is the x parameter matrix, and vstack is to add a column of 1 as the offset term.
[0] An is the parameter matrix and y is the corresponding value of x. The function of the function is to fit k and b by the least square method.
A = [1, 2, 3] b = [4, 5, 5, 6]
A.append (b)
A = [1, 2, 3, 4, 5, 5, 6]
A.extend (b)
A = [1, 2, 3, 4, 5, 6]
Size usage
Import numpy as np
X=np.array ([1, 2, 3, 4]
[5,6,7,8]
[9, 10, 11, 12]))
Number=X.size # counts all elements in X
X_row=np.size (XPower0) # calculates the number of elements in a row of X
X_col=np.size (XPower1) # calculates the number of elements in a column of X
Print ("number:", number)
Print ("X_row:", X_row)
Print ("X_col:", X_col)
Number: 12
X_row: 3
X_col: 4
The usage of shape
Import numpy as np
X=np.array ([1, 2, 3, 4]
[5,6,7,8]
[9, 10, 11, 12]))
X_dim=X.shape # returns the dimension of the array as a tuple
Print ("X_dim:", X_dim)
Print (X.shape [0]) # number of output lines
Print (X.shape [1]) # number of output columns
X_dim: (3,4)
three
four
The usage of len
Import numpy as np
X=np.array ([1, 2, 3, 4]
[5,6,7,8]
[9, 10, 11, 12]))
Length=len (X) # returns the length of the object is not the number of elements
Print ("length of X:", length)
Length of X: 3
The above is all the content of this article "what's the use of python3?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!