Python Basics - Functions (0414)

1. Explanation of the exercise: What will the following code output? 
def f(x,l=[]):
    for i in range(x):
        l.append(i*i)
    print(l)

f(2)
f(3,[3,2,1])
f(3 )

answer:

2. Keyword of function

Third, the parameters of the function

4. Anonymous functions

5. Higher-order functions (used more four sorted )

6. List Builder (Nine Palaces)

       list comprehension

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324551667&siteId=291194637