1 # 1. 判断gl_num和gl_list的值
 2 def demo(num, num_list):
 3     num += num
 4     num_list += num_list
 5 
 6     print(num)  # 18
 7     print(num_list)  # [1, 2, 3, 1, 2, 3]
 8 
 9     print("函数完成")
10 
11 
12 gl_num = 9
13 gl_list = [1, 2, 3]
14 demo(gl_num, gl_list)
15 print(gl_num)  # 9
16 print(gl_list)  # [1, 2, 3, 1, 2, 3]
 1 # 2.请说出 list1,list2,list3 的值是什么,并且说明为什么
 2 def extendlist(val, lis=[]):
 3     lis.append(val)
 4     return lis
 5 
 6 list1 = extendlist(10)
 7 list2 = extendlist(123, [])
 8 list3 = extendlist('a')
 9 
10 print(list1)  # [10, 'a']
11 print(list2)  # [123]
12 print(list3)  # [10, 'a']
 1 # 3.请说出acts[0](2)的值,并且说明为什么
 2 def makeActions():
 3     acts = []
 4     for i in range(5):
 5         acts.append(lambda x: i ** x)
 6     return acts
 7 
 8 
 9 acts = makeActions()
10 print(acts[0](2))  # 16
11 print(acts[1](2))  # 16
12 print(acts[2](2))  # 16
13 print(acts[3](2))  # 16
14 print(acts[4](2))  # 16
15 
16 print("~"*50)
17 
18 def makeActions():
19     acts = []
20     for i in range(5):
21         acts.append(lambda x, i=i: i ** x)
22     return acts
23 
24 
25 acts = makeActions()
26 print(acts[0](2))  # 0
27 print(acts[1](2))  # 1
28 print(acts[2](2))  # 4
29 print(acts[3](2))  # 9
30 print(acts[4](2))  # 16