Python study notes (1)

Classification: Employment guidance 1658 people read Comment(3) Collection Report
First, definition and configuration

PythonIs an easy to learn, easy to use language. Because his code is clear, easy to understand, can help students not to tangle in the code of complex syntax, enjoy the fun of programming is an object-oriented language, and its scalability and portability are very good. You can select the code from a module, you can also read from another module properties. Many "predecessors" has developed a rich and colorful extension of the library, regardless of what you want to develop the application, are likely to find a similar code module, and even plug and play". On any platform with Python written in general software can be modified or even completely without modification can run on other platforms.



Two, basic concepts

First look at a section of code




Very simple, entire section of code is to assign values to variables and print output variables ~ ~ (well, compared with the C language, does not require includes file header, also do not need to write the main function, the important is do not need to write the variable type, also do not have to write a semicolon. Output is also simple!) , which is very convenient, regardless of the value of the integer, string or other types of value, directly assigned to the variable.
If the representation is the 8 - band, 16 - band or long - shaped value, just in front or back with a tag to see the above code.
Long integer in Python is different from the long integer in the C or other compiled languages, it does not need to be in the range of 32 or 64. Python long integer length is related to the size of your machine supported (virtual) memory. In other words, as long as the content is sufficient, it can express a great deal of numerical value.

Then as a high-level language must have several "default" data types, as follows







Through the above code, it can be seen that, although the Python does not have a large bracket, but it is required to use 4 spaces to represent each level of indentation (but in the actual preparation of the number of spaces can be defined, but to meet the same number of spaces between each level of indentation). As the indentation depth increases, the level of code block is deepened, and the code block with no indentation is the highest level. This indentation is strictly controlled, the interpreter will be judged according to the different of the current code is part of the current code, that is to say, the role of the replacement of the indentation.

Then introduce the function how to write, first in function former def show that behind is a function, then in parentheses at the end of the colon, indented part is a function of the content.




Another five operations

Run it can be found that the division of which is obtained by the integer, if you want to get a small number, you need to introduce an external module to achieve this function, as follows




Note that future is two ~ ~.
Then is a string, a single quotes, double and three quotes, respectively, for different situations, the general situation of single and double quotes general, but encountered a string in a single quotes it is best to use double quotes to indicate that, of course, can also use \ escape character of the string in single quotes indicate. And the three quotes used in the string is too long to write the branch.

Top
0
Step
0
Guess what you're looking for.
View comments
* above the user's comments only represent their personal views, do not represent the views or position of the CSDN website
    Personal data
    • Visit377653 times
    • Integral:4495
    • Grade
    • Rank:3325th
    • Original104
    • Reprint:82
    • Translation:0
    • Comment:1080
    Contact us
    Contact person: Yao Xi
    Phone: 51661202-381
    Email: yaoxi@PROG3.COM
    QQ number: 2411559571
    Club website: http://prog3.com/sbdm/student