Python3 digital

Python3 data type for storing digital values.

It is not allowed to change the data type, which means that, if you change the value of the digital data type, will be re-allocated memory space.

Python supports three different values ​​of different types:

Integer (int): usually referred to as an integer or an integer, is positive or negative integer, with no decimal. python3 is no limit to the size of the integer. Long can be used as the type of use

Float (float): float fractional part is composed of an integer part, it may be a floating-point represented by the scientific notation.

Complex (complex): the complex is composed of a real number part and imaginary number part, they can be a float.

 

Python numeric type conversion

Sometimes we need to built-in data type conversion, data type conversion, just need to type the data as a function name.

int (x): to convert into an integer x

flaot (x): converts into a floating point number x

complex (x): x converted into a complex number, x is the real part, imaginary part is 0

complex (x, y): x and y are converted into a complex number, x is the real part, imaginary part to y.

 

Python number crunching:

It may be used as +, -, *, / digital computing expressions used.

 

Digital function

function

description

abs(x)

Returns the absolute value of digital

ceil(x)

Returns the integer into the

exp(x)

Returns e raised to the power x

fabs(x)

Returns the absolute value of a float

floor(x)

Returns the integer rounded floor (4.9) = 4

log(x)

Returns the logarithm to the base e

log10(x)

Returns the logarithm to the base 10

max(x1,x2…)

Is returned to the maximum value given parameter

(x1, x2, ...)

Is returned to the minimum value of the given parameter

modf(x)

Returns the integer part and a fractional part of x, sign of the value of the two parts of the same, in floating-point integer part

pow (x, y)

Value computing x ** y

round(x,[,n])

Returns the four-color into the floating-point number five

sqrt(x)

Returns the square root of x

 

Random number function:

Random number can be used for numbers, gaming and security fields, often nested into the algorithm to improve the efficiency and improve the safety of the procedure.

Python comprising conventional random function

function

description

choice(seq)

A randomly selected element from the sequence.

random.choice (range (10)), a randomly selected integer from 0-9

randrange(start,stop,step)

Acquiring a random number by the specified base set of increments within a predetermined range from the default value of 1 base

random()

Generate a random real number (0, 1) in the range of

seed(x)

Changing the random number generation number seed.

shuffle(lst)

All elements of a sequence of random ordering

uniform(x,y)

Next generates a random real number, it is [x, y] in

 

Trigonometric functions:

function

description

acos(x)

Returns the inverse cosine of x radians

asin(x)

Returns the arc sine of x radians

atan (x)

Returns the arctangent of x radians

atan2 (y, x)

Returns the given values ​​of x and y coordinates of the arctangent

cos(x)

Returns the cosine of x radians

hypot (x, y)

Returns the Euclidean norm (sqrt (x * x + y * y)

sin (x)

Returns the sine of x radians

tan (x)

Returns the tangent of x radians

degrees(x)

The loaded into the angle in radians

radians(x)

Converts degrees to radians

 

Mathematical Constants

constant

description

pi

PI

e

Constants of nature

Guess you like

Origin www.cnblogs.com/wanghao-boke/p/11389293.html