The concept of BIF (built-in function), what is a built-in function, is a function that Python has already defined, does not need to be defined by the person, and can be used directly by the function, then what are the BIF?
You can enter this code in the interactive Interface (IDLE), noting that both sides are double underlined
You can see which bif are available in different Python versions
Just look at these can be clearly see PYTHON3 and Python2 still have a lot of difference, want to see which BIF usage directly help () It look official document on line, here to say is, Python official code actually very few grammar, basically are very simple English, To learn that programming is not possible without learning English, how to master the common terminology of the development language, and official documents than any other parsing to more formal and accurate, to learn to read official documents.
At the end of the previous chapter you should see the operation, yes, any kind of development language can be calculated, you have to use it as a calculator I can not do.
Speaking of which, nature is involved in the operator:
1. Arithmetic operators
+,-,* (note is the asterisk, not the letter X), which is learned in mathematics, not much to say
,/,% these are all related to Division, but the representative is different. First say/, there are different results in Python2 and Python3:
Above is Python2, the following is python3,/default in Python2 is normal except, but to the decimal part, if you want to achieve the result of Python3, that is equal to how much is equal to how much, need the following advanced syntax:
This "from __future__ Import Division" syntax is not to be said, and later in the module chapter, you know this usage is OK
Do you think, wow, good pit ah, a simple division operation, can not get an original result, yes, Python official learned that this also improved to Python3, how much is how much
Take a modulo operation, or call an entire budget
% take remainder operation
This take-rest operation will play a big role in the back
2. Comparator:
> Greater than
>= greater than or equal to
< less than
<= less than or equal to
= = equals (Note that the = = is not equivalent to IS)
! = does not equal (<> also indicates not equal)
= Assignment (x=y=z chain Assignment)
3. Logical operators:
In belongs to
Or or (note the difference from other languages, where the or is not equivalent to |,| has other meanings)
Not in does not belong to
is equivalent to
The first three in high school math in the collection of the time you have learned, do not say, the use of the back when you will experience
is primarily is, it is the use of judgment is not its own, such as:
Here the ID () is a built-in function, you can see the object's memory space in the ID, and is the use of matching can really judge it is not himself, but here are the same, it seems that there is no problem, right? Because of the same result, do you think that = = is?
Here again with a later mention of the knowledge, list, I am sorry, because the knowledge point is so cross, in order to explain the current = = is not the same as is, have to mention the list, the following will be explained, let alone this problem
See, at this point A is B returns false, but the ID is still the same. so = = is not the same as is remember this.
4.** Power operation
5. Positive and negative number:
+,-(This is not the addition and subtraction of arithmetic operations character)
6. Bitwise operations
&: Bitwise AND operation, bitwise refers to the conversion of a number to binary, then these binary bitwise and operations, that is, similar to and operations
Example:>>> a=7&18 #7二进制为111 converted to binary: 00000111
>>> a #18 convert 10010 to binary: 00010010, two for operation,
2:0000010, 2
|: Press for OR, bitwise refers to converting a number to binary, and then these binary bitwise OR operations, which are similar to or operations #注意, where the "|" Not equivalent to "or" (note differs from C language)
Example:>>> b=7|18 #7二进制为111, converted to binary: 00000111
>>> b #18 to 10010, converted to binary: 00010010
23 # 00010111, 23
Cases:
^: Bitwise XOR, bitwise refers to converting a number to binary, then the binary bitwise OR operation, the difference is 1, the same is 0
Cases:
>>> c=7^18 #7二进制为111, 00000111
>>> c #18为10010, 00010010
21 # 00010101, 21
~: bitwise rollover, i.e. ~x=-(x+1)
Example:>>> a=~18 ~18=-(18+1)
>>> A
-19
<<: Shift left, for example 18 is 00010010
Move left one unit 00100100, that is 36, move left one unit is equal to multiply by 2, Shift left N units is multiplied by 2 n power
Cases
>>: Bitwise Right SHIFT, for example 18 is 00010010
Move right one unit 00001001, or 9, move left one unit equal to divide by 2, shift left N units to divide by 2 n power
Cases:
You should have doubts now, if these operators are mixed together, how to calculate? Who starts the calculation first, who calculates it last?
So there's the arithmetic priority:
Yes, that's all the arithmetic priorities, you should think, I'm learning a programming language, I have a priority rule so much, don't I have to recite?
No, basically no backrest, you write code maintenance code at the same time you will naturally remember, and do not remember all, usually use these:
Priority from left to right high to Low:
Power Operation (* *), sign (+,-), arithmetic operator (*,/,//,%,+,-), comparison operator (<,<=,>,>=,==,!=), logical operator (Not,and,or,is)
In fact, these priorities are basically the same as in math.
The only thing to note is:
Where the left sign priority of the power operation is lower than the right-hand priority:
At this point, the real pre-concept and rules you have mastered, the back will enter the true baptism of the road.
"Python" reveals common built-in functions and data types from simple cases