Python Learning notes Custom function

Source: Internet
Author: User


Python is an object-oriented, literal translation of computer programming language. The Python syntax is concise and clear, with a rich and powerful class library.

It is often nicknamed the Glue language, which makes it easy to connect the various modules made in other languages (especially C + +) easily.
A common application scenario is to use the Python quick-build prototype (sometimes the final interface of the program), and then rewrite it with C + + in a more appropriate language, such as a graphics rendering module in the 3D game, with a very high speed requirement.

def function name (parameters):

function body


has already been defeated by Python without a variety of terminators, look at functions, even parameters do not need to define data types, function definition should be unconventional, most languages are using function, this goods must use Def

, Def is not in C pretreatment, a little understand.

All the functions, structures, and loops in Python are: Start with no terminator. The readability of the program can become worse. Can not like C, a piece of, I love to write a few functions to write several functions, call each other and then instantiate, all kinds of cool, python can not see, it seems to be very test write the skill of annotation


# Python Custom functions

# Custom Function Keywords: def

Def defname ():

Print (123)

Print (Defname ())

Note

# Pass a variable to a function, the function operates on it, but the original integer variable does not change

# Pass a table (array) to a function, the function is manipulated, the original table (array) is changed

# for variables of the base data type, when a variable is passed to a function, the function copies a new variable in memory, which does not affect the original variable. (This is called value delivery)

# for tables (arrays), the table (array) passed to the function is a pointer to the position of the sequence in memory, the operation of the table (array) in the function will be in the original memory, thus affecting the original variable. (This is referred to as a pointer pass)

#=================================================================#

# Python function range ()

# Create sequence arrays, for example: the number of [0,1,2,3 ...] array elements depends on the range () parameter value (-1)

Range (5) #[0,1,2,3,4]

#=================================================================#

# PYQT Draw interface layout, generate PY source file (command) via cmd:

# pyuic4.bat qt file path (relative/absolute)/file name. ui-x-o The path/file name to be saved. py

# x is followed by a file that needs to be converted.

#-O followed by filename, the name of the Python program you want to export (not in Chinese)

# c:/python33/lib/site-packages/pyqt4>pyuic4.bat F:/python/qt.ui-x-O f:/python/gt.py

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.