Think Python Chapter3

Source: Internet
Author: User

3.1 Built-in function

Type (All) = <class ' int ' >

Int (' + ') =>32

int (3.9) = 3

Int ( -2.3) =>-2

Float (+) = 32.0

Float (' 3.14159 ') =>3.14159

STR (+) = ' 32 '

STR (3.14159) = ' 3.14159 '

3.2 Define a function

Defining a function creates a function object, which has type function.

You can run it with to create a function before. In other words, the function definition had to run before the function gets called.

The rules for function names is the same as for variable names:letters, numbers and underscore is legal, but the first Character can ' t be a number.

Single quotes and double quotes do the same thing; Most people with single quotes except in cases like this where a single quote (which was also an apostrophe) appears in the String.

function definitions get executed just like other statements, but the effect is to create function objects. The statements inside the function does not run until the function is called, and the function definition generates no OUTPU T.

3.3 Flow of execution

Execution always begins at the first statement of the program. Statements is run one at a time and in the order from top to bottom.

function definitions does not alter the flow of execution in the program, but remember that statements inside the function D On ' t run until the function is called.

A function call was a detour in the flow of execution. Instead of going to the next state-ment, the flow jumps to the body of the function, runs the statements there, and then Comes back to pick up where it left off.

3.8 Variables and parameters are local
When you create a variable inside a function, it's local, which means that it's only exists inside the function.

Think Python Chapter3

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.