Take the time to look at Python today. It feels good, it's different from a compiled language. C,c++,java,c# and so on are all compiled languages, that is, you need to compile first, and then
In the link, only binary executable files are generated (except java,c#, which requires a virtual machine to run), but they also need to be compiled.
Python is a typical interpretive language. His biggest feature is similar to the scripting language, such as: Shell programming, JS, etc., do not need to compile.
Learn the basics of Python today: including: statements, defining variables, defining functions. The following is a summary of the content of the study, so that later can be warm
and know the new.
Statement:
The logical and physical lines of a Python statement are introduced first, and the physical line is the actual one that can be seen in the file. This is the physical line, and the logical line refers to a
A semicolon is a logical line, and a physical line can have more than one logical line. But the default Python rule is that a physical line corresponds to a logical line.
Indent: The indentation of Python corresponds to the statement block of C. is {}, indentation is used for if branches, while statements, function definitions, and so on.
Define variables:
The definition of a variable does not require a specified type. Kind of like JS
Example: length = 10; length is defined as the shaping variable. There are four types of values: Shaping, long integer, floating point, plural. Note Python can define complex numbers. This and
Many languages are different.
Statement BLOCK:
If,while statement block,
If condition:
Statement 1
Statement 2
。。。
Elif Conditions:
Statement 1
Statement 2
。。。
Else
Statement 1
Statement 2
。。。
This is the IF syntax.
While
while
条件:
Statement 1
Statement 2
。。。
else
:
Exit statement
This is the while statement definition.
for
变量
in
range
(
起始值
,
结束值
):
语句
else
:
退出语句
This is the FOR Loop statement definition. He is equivalent to C's for (variable = start value; variable < end value; variable self-increment, or decrement) {statement}
function definition:
def function name (parameter list):
function block
Note that the parameter list can set default parameters. and C + + a bit similar;
For example:
def
fun
(first, second =
1,third = 2
):
Statement block
Can be called as follows:
Fun (1), 1 will pass to first
Fun (first,2), 1 will pass to second
Fun (1,third = 3), 1 is passed to first,3 is an explicit assignment.
Note: It is not possible to define this: def fun (first = 1,second,third =3) Because the default first cannot be resolved in the end whether it is the number one or the second.
Function call:
Fun (1,1,2)
File name definition:
Python's default file suffix, py, allows you to add Python paths to system variables. This can be called at the command line.
Ython Learning Notes (a) statements, variables, functions