本文共 2903 字,大约阅读时间需要 9 分钟。
To delete the reference to a number object using del. The syntax of the del statement is: del var1[,var2[,var3[....,varN]]]]
Python中不同数据类型之间的转换规则(限number)
1 复数 2 浮点数 3 长整形 4 整形
绝对值函数abs对复数的作用则是 x+yi abs=xX+ yy开平方
Type int(x) to convert x to a plain integer.
Type long(x) to convert x to a long integer.
Type float(x) to convert x to a floating-point number.
Type complex(x) to convert x to a complex number with real part x and imaginary part zero.
Type complex(x, y) to convert x and y to a complex number with real part x and imaginary part y. x and y are numeric expressions
Python includes following functions that perform mathematical calculations.
Function | Returns ( description ) |
---|---|
The absolute value of x: the (positive) distance between x and zero. | |
The ceiling of x: the smallest integer not less than x | |
-1 if x < y, 0 if x == y, or 1 if x > y | |
The exponential of x: ex | |
The absolute value of x. | |
The floor of x: the largest integer not greater than x | |
The natural logarithm of x, for x> 0 | |
The base-10 logarithm of x for x> 0 . | |
The largest of its arguments: the value closest to positive infinity | |
The smallest of its arguments: the value closest to negative infinity | |
The fractional and integer parts of x in a two-item tuple. Both parts have the same sign as x. The integer part is returned as a float. | |
The value of x**y. | |
x rounded to n digits from the decimal point. Python rounds away from zero as a tie-breaker: round(0.5) is 1.0 and round(-0.5) is -1.0. | |
The square root of x for x > 0 |
Random numbers are used for games, simulations, testing, security, and privacy applications. Python includes following functions that are commonly used.
Function | Returns ( description ) |
---|---|
A random item from a list, tuple, or string. | |
A randomly selected element from range(start, stop, step) | |
A random float r, such that 0 is less than or equal to r and r is less than 1 | |
Sets the integer starting value used in generating random numbers. Call this function before calling any other random module function. Returns None. | |
Randomizes the items of a list in place. Returns None. | |
A random float r, such that x is less than or equal to r and r is less than y |
Python includes following functions that perform trigonometric calculations.
Function | Description |
---|---|
Return the arc cosine of x, in radians. | |
Return the arc sine of x, in radians. | |
Return the arc tangent of x, in radians. | |
Return atan(y / x), in radians. | |
Return the cosine of x radians. | |
Return the Euclidean norm, sqrt(x*x + y*y). | |
Return the sine of x radians. | |
Return the tangent of x radians. | |
Converts angle x from radians to degrees. | |
Converts angle x from degrees to radians.转化为弧度 |
The module also defines two mathematical constants:
Constant | Description |
---|---|
pi | The mathematical constant pi. |
e | The mathematical constant e. |
转载地址:http://snxci.baihongyu.com/