- Built-in functions
-
- INT (x, [, base]): converts a value or string to a decimal number. When base has parameters, X must be a string and base-based. Print int ('20140901', 8) #12345
- All (): If all functions are not 0, or if the element is null, true is returned. Otherwise, false is returned.
- The range () function generates only an object that can be iterated, and the output is not a list. Use List (range () to iterate the objects returned by range into a list.
- Format (value [, format_spec]):
- Format (x, '6. 3f'): In the 6.3f output format, the floating point number is output with a total width of 6 digits and three decimal places.
- If the actual number of decimal places is less than 3, 0 is added. If the number of decimal places exceeds 3, the excess part is rounded to the nearest digit.
For example, if the total width (including one decimal point, plus three decimal places, if there is a sign bit "-", it is also regarded as one digit) is less than 6 digits, then fill in the front space; if the total width exceeds 6 bits, the output is based on the actual width.
- The "" in the print () function must be separated from the variable name.
2. Statement Structure
- Single Branch (if statement), double branch (if, else statement), and multiple branch (if, Elif, else ). Multiple branches only execute the first statement that is true. Therefore, the conditional order of multiple branches affects the execution result of the program.
- Loop Structure: traversal loop (for), conditional loop (while, do not know how many times to use this method ).
The commonly used operator = In a statement is used to determine whether two objects are equal, not whether the values are equal. The letter W = W. Conditional loops are implemented by one condition. A processing operation must be provided in the loop body so that the loop can end. The conditional calculation result cannot always be true. Otherwise, the loop is stuck in an endless loop.
3. nested loop structure:
Pay attention to the level of the statement or statement forging to identify whether it is an outer loop or an inner layer.
The blue font is important and hard to understand.
Built-in functions and control statements