print "hello,python."
print "hello,","python." //会多输出一个空格
print 'hello,''python'
print "hello,","python." //会多输出一个空格
print 'hello,''python'
2015-06-24
def average(*args):
if len(args)==0:
return 0.0
return sum(args)*1.0/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
if len(args)==0:
return 0.0
return sum(args)*1.0/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2015-06-24
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = sum(d.values())
print (sum+0.0)/len(d)
sum = sum(d.values())
print (sum+0.0)/len(d)
2015-06-24
最新回答 / Jeffacode
最好能把上下文全都贴出来,光这行代码看不出要干什么。while里的判断条件是「把列表的第2个元素pop出来看等不等于True」。如果这个判断的目的是看迭代中列表还有没有第2个元素的话,那显然...
2015-06-24
代码如下
L = [75, 92, 59, 68]
sum = 0.0
for in L:+in L
print sum / 4
L = [75, 92, 59, 68]
sum = 0.0
for in L:+in L
print sum / 4
2015-06-23
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for name, score in d:
print name: score
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for name, score in d:
print name: score
2015-06-23
print [m+n+m for m in "123456789" for n in '0123456789']..
2015-06-22