Learning Python Chapter 4 custom functions

Source: Internet
Author: User
Def keywordThe custom function starts with the def keyword followed by the function name, No {} in C #. End the function in indent mode.  In python, user-defined functions must be written before the call statement. (Compilation seems to be compiled from top down) Functions with ParametersFor a function with parameters, directly write the parameter name. If the parameter type is not required, the Data Type Def funname (arg1, arg2) of the input parameter is automatically recognized ): print ("custom function output information") print (arg1) print (arg2 + 1) funname ('parameter 1 information', 123) input () Function with reverse return valueYou do not need to set the type of the reverse return value. The default parameter can be directly equal to the value followed by the default value. Def funname (arg1 = 10): Return arg1n = funname () print (N) N = funname ('12') print (n) n = funname (12) print (n) input () Import reference and namespaceAfter the import, there is no namespace for the file name. The namespace is the file name sub-

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.