This morning the group master turned to look at a mysterious courseware, suddenly learning power overflowing, think Python divided three times to finish too underestimated everyone's strength! After all, everyone is a computer professional background, and currently doing the Code of farming (Code workers, code God) live. And Python is also simple and elegant outrageous, rather than a one-time basic grammar, functions, classes, modules to finish speaking? Bang again and bad three and exhausted, hope that everyone in the interest attenuation before quickly into the cool machine learning world, turn hand for the cloud cover hand for the rain, open a good data excavator, do a good job feature engineering, tune to a good argument. Do not say, as if to see the eyes of everyone longing and flow of saliva ☆\ ( ̄▽ ̄)/$
A single journey, let us finish the last warm-up, and then into the machine learning torrent, to the mid-stream strokes, waves to suppress Feizhou ...
Python basic Syntax 2
I. CONDITIONS and conditional statements
Python is used for conditional judgment on the IF statement, which consists of three parts: the keyword itself, the conditional expression used to determine the true or false result, and a block of code that executes when the expression is true or non-zero;
If expression:
Expr_true_suite;
If expression:
Expr_true_suite
Else
Expr_false_suite
If expression1:
Expr1_true_suite
Elif expression2:
Expr2_true_suite
Second, circular and cyclic statements
1. While
The statement format for the while loop is as follows:
While expression:
Suite_to_repeat
The SUITE_TO_REPEAT clause continues to loop until the expression value returns FALSE.
2. For
The statement format for the For loop is as follows:
For Iter_var in iterable:
Suite_to_repeat
The For loop accesses all elements in an iterative object, such as a sequence or iterator, and ends the loop after all entries have been processed.
Third, function
A mathematical function refers to a corresponding relationship of a single output given an input. The functions in the programming language are similar in meaning, but they are also different. A function is a piece of statement that has a name that you can use repeatedly when you need it. It may require input and may return output.
The statement format of the function is as follows:
def function_name (input):
Function_suite #函数体
Iv. class
A class is a data structure that we can use to define objects. Classes are abstract entities of the real world that appear in a programmatic manner. Instances are the materialization of these objects. In analogy, a class is a blueprint or model used to produce real objects (instances).
The language format of the class is as follows:
Class ClassName (object):
Class_suite #类体
Five, module
A module is the Pyhon highest-level program organizational unit that encapsulates program code and data for reuse. In practical terms, modules often correspond to Python program files. Each file is a module, and the module can be imported into other modules to use the variable names defined in the imported module.
The entire module is imported in the format:
Import Module
Import a function from a module in the following format:
From Somemodule import somefunction
Import multiple functions from a module in the following format:
From Somemodule import Firstfunc, Secondfunc, Thirdfunc
Import all the functions in a module in the following format:
From somemodule Import *
Next week introduce NumPy, do vector, matrix operation of large kill device, array slicing operation is unpredictable, is the dangerously ring machine learning Road on the first large filter! Please expect:)
3-god says to have light, so there is python (bottom)