1.def func1(p):
i1 = len(p)
if i1 > 2:
i2 = p[0:2]
return i2
r = func1([11,22,33,44,55])
print(r)
调用函数得到的结果是:____[11, 22]__________
def func():
total_1=0
total_2=0
for i in range(10):
if i%2==1:
total_1+=i
else:
total_2+=-i
total=total_1+total_2
Return total
调用函数得到的结果是:__5______
3.
tu=[11,22,33,44,55,66,77,88,99,90]
def func(list1):
n1=[]
n2=[]
dir={}
for i in list1:
if i >66:
n1.append(i)
else:
n2.append(i)
dir["k1"]=n1
dir["k2"]=n2
Return dir
调用函数得到的结果是:__{'k1': [77, 88, 99, 90], 'k2': [11, 22, 33, 44, 55, 66]}_________
4.
def demo(*args):
return args * 2
则sum(demo(1,2,3))的值为___12_____;len(demo())等于____0_____。
已知:pf = lambda a,b=2:a + b; 则pf(2) = ____4__;pf(3,4) = _7_____; pf(b=3,a=5) = ____8_____;
5.
def demo(a):
for key in a:
a[key] += 10
则a = {1:10,2:20,3:30};则执行demo(a)后,a = ___{1: 20, 2: 30, 3: 40}____________。