3-god says to have light, so there is Python (next)

Source: Internet
Author: User

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;

    • The syntax for the IF statement is as follows:

If expression:

Expr_true_suite;

    • The Union Else statement syntax is as follows:

If expression:

Expr_true_suite

Else

Expr_false_suite

    • The syntax for combining ELIF statements is as follows:

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)

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.