return sum(float(x) for x in args)/len(args) if len(args)>0 else 0.0
2018-06-06
如果a有N个圆盘,可以看成a有1个圆盘(底盘) + (N-1)个圆盘,首先需要把 (N-1) 个圆盘移动到 b,然后,将 a的最后一个圆盘移动到c,再将b的(N-1)个圆盘移动到c。
题目这么写的话,假设有4个圆盘,难道按照题目的意思,不是应该先从A拿出3个移动到B,再把A最后一个移动到C,然后把B的3个移动到C吗??是我理解这段话有问题吗?
题目这么写的话,假设有4个圆盘,难道按照题目的意思,不是应该先从A拿出3个移动到B,再把A最后一个移动到C,然后把B的3个移动到C吗??是我理解这段话有问题吗?
2018-06-05
print [int(str(m) + str(n) + str(t))for m in range(1,10) for n in range(0,10) for t in range(1,10) if m == t]
2018-06-05
return ((-b+math.sqrt(b*b-4*a*c))/(2*a),(-b-math.sqrt(b*b-4*a*c))/(2*a))
2018-06-05
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
[s.remove(x) if x in s else s.add(x) for x in L]
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
[s.remove(x) if x in s else s.add(x) for x in L]
print s
2018-06-05
def average(*args):
sum = 0.0
for item in args:
sum = sum + item
if len(args) == 0:
return 0.0
else:
return sum/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0.0
for item in args:
sum = sum + item
if len(args) == 0:
return 0.0
else:
return sum/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-06-05
for x in ['0','1','2','3','4','5','6','7','8','9']:
for y in ['1','2','3','4','5','6','7','8','9','0']:
if x+y>'09' and x<y:
print x+y
for y in ['1','2','3','4','5','6','7','8','9','0']:
if x+y>'09' and x<y:
print x+y
2018-06-05
L = [1, 101]
def sum(li):
result = 0;
for item in range(li[0], li[1]):
result = result + item * item
return result
print sum(L)
def sum(li):
result = 0;
for item in range(li[0], li[1]):
result = result + item * item
return result
print sum(L)
2018-06-05