Python Learning (Basic company)

Source: Internet
Author: User

Today finally began the study of Python, as for the history of Python I will not say, Baidu Encyclopedia too detailed, I said here is Kuan Kung in front of the broadsword, too presumptuous, so, nonsense not to say, directly tell me about my shaking learning python harvest bar.

  Installation of 1.Python

The Python installation is very simple, like the language features, easy to learn. Installation without cumbersome configuration environment, as long as the right version, directly select the installation directory, the rest is a fool-like operation, just click on the next step is OK, but the installation is a little bad, there is no desktop shortcut, this has to be manually added, the other in the installation will automatically help you ready.

After the installation is complete, you can use the cmd command line to enter some simple Python program, and detect the environment is normal, but the cmd command line running programs can not be saved, only to detect some simple programs, in the late generally do not use the cmd command line to write programs, if you want to save the written program, At this point, you need to save to the hard disk program, the simplest is the TXT text document. However, txt text document because it is quite simple, so no code is used in the auxiliary functions, such as: Smart tips, grammar error, automatic alignment, auxiliary lines and so on, so use txt text documents to write programs to the programmer's requirements are quite high, because you simply look at the code is difficult to see where there is a problem. This is I recommend a code to write a small program notepad++, the software is very small, the requirements of the environment is very low, and the code is very high recognition, can write many languages of the code, and should have some hints basically have, very suitable for the new handwritten code when used, and this software is completely Chinese, Don't worry about reading a word without knowing what the function is.

2. First program "Hello World"

  After Jenshovan compiled the tool, it was the most exciting moment of our time, a ritual that every ape of the program had to carry out, and this was the expression of the respect of the program ape for the language, which was used to output the phrase "Hello world!" in this language. Of course, I have this python little white today also carried out this ritual, in Python language wrote my first "Hello world!" And put it on the cmd command line to run once, and after this ceremony was completed, it also marked the beginning of my study of the language.

3. Syntax and memory management

The syntax of the Python language is quite simple, the recognition level is quite high, there is no cumbersome,:<> and other symbols to denote different states (previously learned is object-c, each line of code after the end of the use; To end this code, or error) just beginning to see the Python code, suddenly feel the world is full of love, finally do not have to play special symbols, the original code can be so simple, and the effect of recognition is so good. This makes me like this language all of a sudden.

Again memory management: Here it is necessary to add some pictures to explain, so with the addition of direct point, but also convenient for later review and other people's understanding.

Memory management, in short, is the size of the program to occupy space, because each device's memory is limited, in addition to each computer must have a system, (now the mainstream system about 1.5 g) Other memory is you can use the memory space, so you can use the memory is even smaller, once a program does not release memory, then your free memory will be quickly reduced, so that your computer more and more cards, take C language: C language is to manually release the memory, once forgotten to release, Then it will take up memory space forever, so this creates a waste of memory. While the Python language has its own memory recovery mechanism, is automatically recycled to release memory, once the memory is not pointing to it, then this memory will be automatically released by Python, which also makes the memory to avoid waste, but also make the program of higher quality. And how does memory manage it? This has a lot of great God has quite good explanation, the following is attached to the explanation of Baidu Encyclopedia (http://baike.baidu.com/link?url=IfvaVyce2lnSSQxA6I3VFaB0Pg0uUW8_ MHIQF2JIIBHSXMAPC5MNNZUXJDCAJ_YB-9YYC1NQFPYB-GWDCYV1Y_)

3. Common operators

The function of the computer is the operation, and the program is to give the computer a fixed operational logic, so that the computer can be calculated according to human expectations. And the program uses computer language, so we have a few operators commonly used in Python company a bit.

There are many operators in mathematics, but in the program does not need so many complex calculations, as long as there are several commonly used, such as: plus (+), minus (-), multiply (*), except (/), The powers (* *), divide (//), balance (%), and so on, these commonly used computational symbols in junior high school have been completed, Here does not explain the use of these operators, if there is no understanding, please finish Junior high school math and then to learn (*^__^*) hehe ...

After these commonly used operators have finished, the rest is the logical operators, a total of three logical operators: and (and), or (or), but (non), these logical operators are mainly to help us in writing procedures to help us to make conditional judgments, we can write some of these judgments very convenient. In the memory of the time I remember this, (and) is true, a false for false. It means that when using and the condition of both sides must be correct, when the result of judgment is T (correct), if there is a condition is false, then the result is f (false). (in particular, it is important to note that thelogical operators in Python do not support symbols and must be in English words )

Of course, in order to facilitate the operation of the arithmetic can be abbreviated, for example: x+=1 this formula means x=x+1. Such formulas as x*=2, x/=2, and so on, commonly used operators can be expressed in such a way, especially in the loop and judge the most applications.

Python Learning (Basic company)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.