def average(*args):
sum=0.0
if len(args)==0:
return sum
else:
for x in args:
sum+=x
return sum/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum=0.0
if len(args)==0:
return sum
else:
for x in args:
sum+=x
return sum/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2020-01-27
已采纳回答 / qq_长袖流舞_jmnZ04
跳转d盘直接使用“d:”命令,然后使用 “cd \Python27\LearnPython”命令跳转就可以了,直接调用python命令运行这个hello文件,或者直接用cd+绝对路径
2020-01-22
已采纳回答 / weixin_慕的地4489817
类型不一致,如想写成print key+':'+d[key],需要将d[key]变成字符串-->str(d[key]),即,修改代码为print key+':'+str(d[key])全部拼接作为一个字符串,就要要求都是字符串也可以像楼上那样,将要打印的内容分为几个变量,每个变量的类型可以不一致,也是可以的;
2020-01-20
def average(*args):
sum=0.0
i=0
if len(args)==0:
return sum
else:
for x in args:
sum+=x
i+=1
return sum/i
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum=0.0
i=0
if len(args)==0:
return sum
else:
for x in args:
sum+=x
i+=1
return sum/i
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2020-01-20