Python Basics-function adorners, iterators, and generators

Source: Internet
Author: User

1. Function nesting 1.1 function nested call

Nested invocation of a function: in the process of invoking a function, another function is called

def Bar ():     Print (fromthebar. " )def  foo ():    print("from" Thefoo. " )    bar () foo ()
1.2 Finding the maximum value of a function
def max2 (x, y    ): if x > y:        return  x    Else:        return y def max4 (a,b,c,d):     = Max2 (A,    b)= max2 (    res1,c)= max2 (    res2,d)return  = max4 (2,5,3,-4)print(res)
1.3 Function Nesting Definitions

Nested definition of a function: inside a function, another function is defined

def F1 ():     = 1    def  F2 ():        print("fromF2". " )    F2 ()   #  can only be called inside the function F1 ()

Python Basics-function adorners, iterators, and generators

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.