Python supports four different numeric types, including int (integer) long (Long integer) float (floating point actuals) complex (complex number), this article introduces Python four types of numeric values to the code farm, and the friends you need can refer to them.
Numeric data types store values. They are immutable data types, which means changing the value of the numeric data type results in a newly allocated object.
Number objects are created when you assign them a value. For example:
var1 = 1= 10
You can also delete a reference to a numeric object, using the DEL statement.
The syntax for the DEL statement is:
del Var1[,var2[,var3[....,varn] []]
You can use the DEL statement to delete a single object or multiple objects.
For example:
del var del var_a, Var_b
Python supports four different numeric types:
- int(signed integer): usually referred to as an integer or an integer, without a positive or negative integer of the decimal point.
- long (longer integer): or desired, an infinite-sized integer, so to write an integer and an uppercase or lowercase L.
- float(floating point actual value): floats, representing real numbers, fractions divided by integers and fractional parts written. Floats may also be in the scientific notation with e or the instruction of the 10-square é (2.5e2= 2.5x102=250).
- complex (plural): + BJ form, where a, B is a float and J (or J) represents the square root of 1 (this is an imaginary number). A is the true number part, and B is the imaginary one. The complex number is not programmed with Python.
Here are some examples of numbers:
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 |
- Python allows you to use the lowercase of long l, but it is recommended that you use only one uppercase letter L to avoid confusion with the number 1. Python Long integer displays an uppercase letter L.
- A complex number consists of an ordered pair of real floating-point numbers + BJ, where A is real and B is the imaginary part of the complex representation.
Numeric Type conversions:
The Python digital conversion interior contains a common evaluation type of mixed expression. But sometimes, you need to explicitly force a number from one type to another operator or function parameter to meet the requirements.
- The int type (x) converts x to a normal integer.
- long(x) converts x to a long integer.
- float type (x) converts x to floating point number.
- The conversion of complex (x) with True x and imaginary parts is zero to a complex number. The type complex (x, Y) converts X and Y to the X and the imaginary part y complex numbers. X and y are numeric expression built-in number functions:
Original address: http://www.manongjc.com/article/973.html
Python Related information:
Python Basic Syntax Introduction
Python Object-Oriented Programming example explained
Python variable and variable type detailed explanation
Introduction to Python operators and precedence instances
Python If Else statement instance explanation
Python four types of numeric values (Int,long,float,complex) Introduction