del var1,var2 ....
1、 integer (int) It is often called an integer or integer , It's a positive or negative integer , Without decimal point
2、 floating-point (float) It usually consists of an integer part plus a decimal point , Floating point types can also be represented by scientific and technical methods 2.5e
3、 The plural (complex) The plural consists of the real part and the imaginary part , You can use a+bj Express Also available complex(a , b) Express , The real part of a complex number a Deficiency part of harmony b It's all floating point
Sometimes you need some reason to convert the data type to output , Just use the required data type as the function name
1、int(x) take x Convert to an integer
2、float(x) take x Converts to a floating point number
3、complex(x) take x To a complex number , The real part is x, The imaginary part is 0
4、complex(x,y) take x To a complex number , The real part is x, The imaginary part is y
Example : Convert floating-point number to integer output , But the data type has not changed
You can directly operate various expressions in the command-line interpreter
// Divide and conquer What you get is not necessarily a number of integer type , It has something to do with the data type of denominator .
for example :
round(str,length) Retain several decimal places after intercepting the string
abs() Get absolute value
abs(-10)
ceil() Returns an upinteger of a number , namely 3.1 return 4
This function needs to introduce math modular , Otherwise, you will be prompted that this function is not found and not defined
import math
math.ceil(4.2)
fabs() Returns the absolute value of the number ( Floating point numbers )
This function also needs to introduce math modular
a = 10
import math
math.fabs(a)
floor() Returns the rounded value of a number , Such as :math.floor(4.2) return 4
math.floor(4.9)
max()、min() Returns the maximum in the sequence 、 minimum value
min(50,24,36,100,94,241,2166,1)
max(13,51,1563,142,240,74,5000)
pow(x,y) return x**y After the value of
math.pow(2,5)
round(str,length) Retain several decimal places after intercepting the string
Without parameters, it is rounded
Plus the parameter is to keep several decimal places