function |
Description |
int (x [, Base]) |
Convert x to an integer |
Long (x [, Base]) |
Converts x to a long integer |
Float (x) |
Convert x to a floating-point number |
Complex (real [, Imag]) |
Create a complex number |
STR (x) |
Convert object x to String |
REPR (x) |
Converts an object x to an expression string |
eval (str) |
Used to compute a valid Python expression in a string, and returns an object |
Tuple (s) |
Converts a sequence s to a tuple |
List (s) |
Converts the sequence s to a list |
Set (s) |
Convert to Variable set |
Dict (d) |
Create a dictionary. D must be a sequence (key,value) tuple. |
Frozenset (s) |
Convert to immutable set |
Chr (x) |
Converts an integer to a character |
UNICHR (x) |
Converts an integer to a Unicode character |
Ord (x) |
Converts a character to its integer value |
Hex (x) |
Converts an integer to a hexadecimal string |
Oct (x) |
Converts an integer to a octal string |
To view variable data types:
A=3
Import types
Type (a)
Int (a) #转换为整型
STR (a) #转换为字符串
python math function
function |
return value (description) |
ABS (x) |
Returns the absolute value of a number, such as ABS (-10) Returning 10 |
Ceil (x) |
Returns the upper integer of a number, such as Math.ceil (4.1) Returning 5 |
CMP (x, y) |
If x < y returns-1, if x = = y returns 0, if x > y returns 1 |
EXP (x) |
Returns the X power (ex) of E, as MATH.EXP (1) returns 2.718281828459045 |
Fabs (x) |
Returns the absolute value of a number, such as Math.fabs (-10) Returning 10.0 |
Floor (x) |
Returns the lower integer of a number, such as Math.floor (4.9) Returning 4 |
Log (x) |
such as Math.log (MATH.E) return to 1.0,math.log (100,10) return 2.0 |
LOG10 (x) |
Returns the logarithm of an X with a base of 10, such as MATH.LOG10 (100), returning 2.0 |
Max (x1, x2,...) |
Returns the maximum value of the given parameter, which can be a sequence. |
Min (x1, x2,...) |
Returns the minimum value of the given parameter, which can be a sequence. |
MODF (x) |
Returns the integer and decimal parts of x, and the values of the two parts are the same as x, and the integral part is represented by a floating-point type. |
Pow (x, y) |
The value after the x**y operation. |
Round (x [, N]) |
Returns the rounded value of a floating-point number x, such as an n value, that represents the digits rounded to the decimal point. |
sqrt (x) |
Returns the square root of a number x, the number can be negative, and the return type is real, as MATH.SQRT (4) returns 2+0J |
python random number function
function |
Description |
Choice (seq) |
Randomly select an element from the elements of a sequence, such as Random.choice (range (10)), and randomly select an integer from 0 to 9. |
Randrange ([Start,] stop [, step]) |
Gets a random number from the specified range, in a collection that is incremented by the specified cardinality, with a cardinality default of 1 |
Random () |
Randomly generates the next real number, which is in the range of [0,1]. |
Seed ([x]) |
Change the seed of the random number generator. If you don't understand its rationale, you don't have to specifically set Seed,python to help you choose Seed. |
Shuffle (LST) |
To sort all the elements of a sequence randomly |
Uniform (x, Y) |
Randomly generates the next real number, which is within the [X,y] range. |