One, the operator
1. Calculation operators: % modulo - return the remainder; ** power - return x to the y power; // take an integer - return the integer part of the quotient;
py2.x 9/2=4 (requires import module) py3.x=4.5
pycharm editor IDE coding tool: 1. Configuration template. 2. Set the text size. 3. Click Run. 4. Switch python version: file -> settings -> project interpreter -> select version
#!/user/bin/python linux is useful, specify the python path
2. Comparison operator: == equals - whether the objects are equal; ! = not equals - does the comparison object want to wait; <> not equals - does the comparison object want to wait
3. Assignment operator: = simple assignment operator; += addition assignment operator; -= subtraction assignment operator; *= multiplication assignment operator; /= division assignment operator;
%=modulus assignment operator; **=exponentiation assignment operator; //=round division assignment operator
4. Logical operators and or not
5. Member operator in not In
The granularity is different, the former minimum unit is a letter, the latter is an element, and each element is a word.
6. Identity operator: is not is
Second, the basic data type
Integer: int (5)
String: str(5)
List: list (5)
Origin: tuple (5)
dictionary: dict (5)
Third, some languages
for for loop
enumrate: A column is automatically generated and incremented by one. enumerate(li,1)
Note: The input input is a string, and print (li[inp_num]) needs to be a number, so it is converted in one step: inp_num = int(inp)
xrange, range (3) range, used to get the number within the specified range, range(0,1000) xrange, used to get the number within the specified range, xrange(0, 1000). Difference: range directly takes up a lot of memory, xrange is not created directly in memory, and will be created one by one when for is used. for i in xrange(1,1000): print(i)
There is no range in python3, only the range equivalent to xrange