# Python Number(number)

The Python Number data type is used to store numeric values.

The data type is not allowed to change, which means that if you change the value of the Number data type, the memory space will be reassigned.

The following instance will be created when the variable is assigned:

var1 = 1 Var2 = 10

You can also delete some Number object references using the del statement.

The syntax of thedel statement is:

del var1[,var2[,var3[....,varN]]]]

You can delete single or multiple objects by using the del statement, for example:

del var del var_a, var_b

Python supports four different numeric types:

**Int**- Usually referred to as an integer or integer, is a positive or negative integer without a decimal point.**long integers**- an integer of infinite size, the integer being an uppercase or lowercase L.**floating point real values**- The floating point type consists of an integer part and a fractional part, and the floating point type can also be represented by scientific notation (2.5e2 = 2.5 x 10^{2}= 250)**complex numbers**- The complex number consists of a real part and an imaginary part, which can be represented by a + bj, or complex(a, b), the real part a and the imaginary part b of the plural It is floating point type.

int | long | float | complex |
---|---|---|---|

10 | 51924361L | 0.0 | 3.14j |

100 | -0x19323L | 15.20 | 45.j |

-786 | 0122L | -21.9 | 9.322e-36j |

080 | 0xDEFABCECBDAECBFBAEl | 32.3+e18 | .876j |

-0490 | 535633629843L | -90. | -.6545+0J |

-0x260 | -052318172735L | -32.54e100 | 3e+26J |

0x69 | -4721885298529L | 70.2-E12 | 4.53e-7j |

- Long integers can also use lowercase "L", but it is recommended that you use uppercase "L" to avoid confusion with the number "1". Python uses "L" to display long integers.
- Python also supports complex numbers, which consist of real and imaginary parts, which can be represented by a + bj, or complex(a,b). The real part a and the imaginary part b of the complex number are both floating point type

## Python Number Type conversion

int(x [,base ]) willxConvert to an integer long(x [,base ]) willxConvert to a long integer float(x ) willxConvert to a floating point number complex(real [,imag ]) Create a plural str(x ) Object x Convert to string repr(x ) Object x Convert to an expression string eval(str ) Used to calculate valid in a stringPythonExpression and return an object tuple(s ) Sequence s Convert to a tuple list(s ) Sequence s Convert to a tuple... chr(x ) Convert an integer to a character unichr(x ) Convert an integer toUnicodecharacter ord(x ) Convert a character to its integer value hex(x ) Convert an integer to a hex string oct(x ) Convert an integer to an octal string

## Python math module, cmath module

The functions commonly used in mathematical operations in Python are basically in the math module and the cmath module.

The Python math module provides a number of mathematical operations on floating point numbers.

The Python cmath module contains some functions for complex operations.

The function of the cmath module is basically the same as the math module function. The difference is that the cmath module operates on complex numbers, and the math module operates on mathematical operations.

To use the math or cmath function you must first import:

import math

View math to see what's in the package: