Today this article is to share some of the cloud computing development tutorial, explaining that today: Python data types of numbers.
The value of the variable is stored in memory, that will open up a space in memory to create variables.
The computer is used to assist humans in program design also mapped display classification of the world, in order to abstract analysis.
Based on the data type of the variable, the interpreter allocates specified memory, and decide what data can be stored in memory.
Thus, the variable can specify different data types, these variables may be stored integer, decimal or character
PYTHON five standard data types:
Numbers (numbers)
String (String)
List (list)
Tuple (tuple)
Dictionary (dictionary)
Digital type
for storing a value, the data type is immutable.
Changing the numeric data type will be assigned a new object.
Digital type of object creation:
When you specify a value, Number object is created:
var1 = 1
var2 = 10
Use Del to remove some references to objects statement
del statement syntax is:
del var1 [, var2 [Vr3 [... characters]]]]
E.g:
del var
del var_a, var_b
Python supports four different types of numbers:
int Signed integer
long long integer [may also represent octal and hexadecimal] L (python3.5 has no)
float float
complex complex
Some numerical examples 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 integer can also use lowercase "L", it is recommended to use a capital "L", to avoid the number "1" confusion.
Python also supports complex, the complex composed of a real part and an imaginary number part, may be used a + bj, or Complex (a, b) indicates, the real part and the imaginary part b is a floating-point
Int integer range represented by (2.0):
-2,147,483,648 to 2,147,483,647
-2 31-2 31-1
test:
a = 2147483647
type(num)
<type ‘int’>
a = 2147483648
type(num)
<type ‘long’>
Long Range Long represented by (2.0):
Great, almost arbitrarily large integers can be stored
Long arbitrarily defined:
num = 123L // added after the integer L
type(num)
<type ‘long’>
Float Float:
f=12
type(f)
<type ‘int’>
f=12.0
type(f)
<type ‘float’>
Complex types:
Applied to a system analysis, signal analysis, quantum mechanics, theory of relativity, applied mathematics, fluid mechanics, fractal
j=3.12
type(j)
<type ‘float’>
j = 3.12j // j plus the original digital basis
type(j)
<type ‘complex’>
Bool type:
Strictly speaking, bool type is the type bool
bool (Boolean)
Real or fake
1 or 0
True or False
a=1==1
a
True
a=bool(1==1)
a
True
a=bool(1==“1”)
a
False
type(a)
<type ‘bool’>