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
代码如下
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