Python ()

Source: Internet
Author: User

Ternary operations

Format:

Variable = condition Returns true result of the IF condition else condition returns false

Condition: 1, must have the result. 2, there must be if. 3, can only be a simple result

Namespaces and scopes for functions built-in namespaces:--python interpreter

The Python interpreter is the first name that can be used when it is started stored in the built-in namespace, and the built-in name is loaded into memory when the interpreter is started.

Global namespaces:--The code we write, but not the code in the function

is the process of executing from top to bottom of the program loaded into memory, and placed all of our set of variable name and function name.

Local namespaces:--functions

is the name defined inside the function, which produces the namespace when the function is called, and the namespace disappears as the function executes.

Order of loading and taking values between three namespaces:

Load order: Built-in namespaces (program run full load)--Global namespace (program run: Load from top to bottom)--local namespace (program running: Call is load only)

Value:

Built-in namespaces, local namespaces, and global namespaces, local call spaces

x = 1def  F (x):    Print(x)print(10)

Global invocation: Built-in namespaces, global namespaces

x = 1def  F (x):    Print(x) F (ten)print(x)

Local: You can use names in global, built-in namespaces

in global: You can use names in built-in namespaces, but not in local

in Built-in: cannot use local and global names

Python ()

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.