Article Directory
1. Programs
1.1 What is the program
Our program is compiled procedures,What is the program?
- Write out in one languageLogically, executable, but the results haveDocuments.
1.2 How the program is executed
ThenThe implementation of the program is how to make?
In the end we want to run the computer code, we need more thanThree parts,:
- the CPU : central processing unit, a large scale integrated circuit,Responsible for data processing and calculation。
- Memory :Temporary storage of dataAnd then to G units (maximum 32G), power data will disappear. Memory speed, but a small space, the unit price is relatively high.
- Hard disk :Permanently store dataTo T units. Slower, larger space, the unit price is relatively low.
The implementation of the principles of the program :
- Before executing the program,Stored in the hard disk。
- When you want to run a program that allows the operating system firstcpu hard copy of the program into memory。
- cpu execute code in program memory. That is in memory and cpu programs interact.
1.3 The role of the program
Procedure is used to process data。
2. Variable
2.1 What is a variable
We use aPointing to a memory address mark, When we quote a memory address, then we can directly use this flag, thisMark is variable。
Variable is a reference to one end of the recording memory address space.
2.2 define the variable
In python we want to define variables:
>>> a = 1
>>> a
1
# a这个变量引用了记录1这个信息的内存地址空间。
Note : variable nameWhen the first occurrence is the definition of variables,appearing againYesBefore the direct use of variables。
2.3 specification variable name
The variables into pythonIdentifiers and Key Words。
2.3.1 Identifier
- Identifier: programmer-defined variable names, function names.
Identifier canLetters, digits, and underscores, can not start with a number, must be unique keyword。
We look at the next practice, which of the following is not correct identifier, incorrect circled.
With practice we summarize: identifiersIt can contain keywords, but not the same as keyword。
2.3.2 Keyword
- Keywords: internal identifier python has been used.
Keywords haveSpecial function and meaning. DeveloperDo not allow the same keywords and definitionsNames and identifiers.
weView python keywords:
2.3.3 naming variables
Naming variables can beAs a convention, with absolutely no other way to force,The purpose isDo not increase the readability of the code。
Note : python identifier is inCase sensitiveof.
- Definition of variables, in order to guarantee code format, each of the left and right sides of the equal sign == leave a space ==.
- In python, if the variable name requires two or more words, you can follow what way.
Rules are as follows :
- Each word useLower case letters。
- Between wordsUse _ underscore links。
- 如:first_one,last_one…
2.3.4 hump nomenclature
When the variable name isTwo or more wordsIt can be used hump nomenclature.
Small hump nomenclature:
- The first word beginning with a lowercase letter, the first letter of the follow-up letter capitalized.
- firstName,lastName
Large hump nomenclature:
- The first letter of each word in upper case letters.
- FirstName,LastName