def average(*args):
sum=0
n=0
for x in args:
sum+=x
n+=1
if n==0:
return 0.0
else:
return sum*1.0/n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum=0
n=0
for x in args:
sum+=x
n+=1
if n==0:
return 0.0
else:
return sum*1.0/n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2014-12-03
为什么答案是 months = set(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']) 这个呢, 这个答案中不包括'Sun'啊
2014-12-03
y=(-b-math.sqrt(b*b-4*a*c))/2*a改成y=(-b-math.sqrt(b*b-4*a*c))/(2*a)不然它相当于 y=(-b-math.sqrt(b*b-4*a*c))
2014-12-02
# -*- coding: utf-8 -*-
d ={
'123': [1, 2, 3],
123: '123',
('a', 'b'): True
}
print d[('a', 'b')]
可以输出啊,不是不能用list做key么?
d ={
'123': [1, 2, 3],
123: '123',
('a', 'b'): True
}
print d[('a', 'b')]
可以输出啊,不是不能用list做key么?
2014-12-02