First thing to remember: object thinking: All things are objects!
- Accurate Description python an object that requires "identity, type, value" from three dimensions.
>>> 520
520
>>> 55555555555555555555555555555
55555555555555555555555555555L
>>> 3.1415926
3.1415926
>>>
int integers : 520
Long large integers : Python automatically converts large integers and displays an l at the end;
float floating point number: 3.1415926
two built-in functions (Build-in function):
Identity ID (): View the object memory address.
>>> ID (520)
38401608L
>>> ID (55555555555555555555555555555)
38334056L
>>> ID (3.1415926)
32795904L
>>>
Types type (): View Object types.
>>> Type (520)
<type ' int ' >
>>> type (55555555555555555555555555555)
<type ' Long ' >
>>> type (3.1415926)
<type ' float ' >
>>>
The value object itself, the above example is a numeric value.
object has type, variable no type!
>>> x=520
>>> x
520
>>> x=110
>>> x
110
>>>
X is a variable, assign a value of 520 to it, and then assign a value of 110 to it; X is like a label;
x as a variable, no type;
Type (x) returns the value of the x corresponding to the kind;
>>> x=110
>>> type (x)
<type ' int ' >
>>> x=55555555555555555555555555555
>>> type (x)
<type ' Long ' >
>>> x=3.1415926
>>> type (x)
<type ' float ' >
>>>
Add +, minus-, multiply *, divide/, computer and math arithmetic rules.
>>>
2
>>> 1+1.0
2.0
>>> 1.0+1.0
2.0
>>> type (1.0+55555555555555555555555555555)
<type ' float ' >
>>>
Need to note:
Float floating-point +int integer =float floating-point type
float float type +long long integer =float floating point type
- Integer overflow problem:
Python solves this problem for us, supporting an "infinite precision" integer, as follows:
>>> 2**1000
10715086071862673209484250490600018105614048117055336074437503883703510511249361
22493198378815695858127594672917553146825187145285692314043598457757469857480393
45677748242309854210746050623711418779541821530464749835819412673987675591655439
46077062914571196477686542167660429831652624386837205668069376L
>>>
1. Python basic Object Type----number