Python return and lambda functions

Source: Internet
Author: User

Return has two functions:

1. Used to return the run result of a function, or to call another function. such as the Max () function

>>> def fun (A, B):   

2. The sign of the end of the function. As soon as the return is run, the function is forced to end. The program after return will not be executed.

>>> def fun (A, B): Return (' Don't run the following statement! ')     #函数不在往下运行. If A>b:print (a) >>> fun (8,1)        #运行到 return, do not run behind the IF statement ' do not run behind the statement, so far! ' >>> >>> def fun (A, B):      

If the function does not write a return, in fact the function runs at the end of the default execution of return None.

>>> def fun (A, b):    #这里的return返回函数结果return (A, b) >>> a = Fun (+) >>> print (a)          # Verify returned results (1, 2) >>> def fun (A, b):  #这个函数里面就没有 Returnprint (A, b) >>> a = Fun (5,6)   5 6>>> Print (a)    

  

 

Python return and lambda functions

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.