def average(*args):
t=sum(args)+ 0.0
return t and (t / len(args))
t=sum(args)+ 0.0
return t and (t / len(args))
2015-04-10
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
else:
if x%2==0:
continue
sum=sum+x
print sum
感觉这样比较好理解额
x = 0
while True:
x = x + 1
if x > 100:
break
else:
if x%2==0:
continue
sum=sum+x
print sum
感觉这样比较好理解额
2015-04-10
def move(n, a, b, c):
if n < 1:
return;
if n == 1:
print a,'-->',c
else:
move(n - 1, a, c, b)
print a,'-->',c
move(n-1, b, a, c)
move(4, 'A', 'B', 'C')
if n < 1:
return;
if n == 1:
print a,'-->',c
else:
move(n - 1, a, c, b)
print a,'-->',c
move(n-1, b, a, c)
move(4, 'A', 'B', 'C')
2015-04-10
x1 = 1
d = 3
n = 100
x100 =x1+(n-1)*d
s =(x1+x100)*n/2
print s
d = 3
n = 100
x100 =x1+(n-1)*d
s =(x1+x100)*n/2
print s
2015-04-09
def quadratic_equation(a, b, c):
st = b*b-4*a*c
if st < 0:
return NONE
elif st == 0:
return -b / a / 2
st = math.sqrt(st)
return (-b + st)/a/2,(-b - st)/a/2
st = b*b-4*a*c
if st < 0:
return NONE
elif st == 0:
return -b / a / 2
st = math.sqrt(st)
return (-b + st)/a/2,(-b - st)/a/2
2015-04-09
最新回答 / Ruskee
一个是集合,一个是元素,元素 in 集合,如果要打印字符串是全大写的,可以考虑这样 print "大写的" if s == s.upper() else "非全大写的"
2015-04-08
最新回答 / Ice_The_Prince
我的理解是一共n个盘子,只有1是可以自由移动的也就是最上面的盘子,而除了这个盘子剩下的就是n-1都在下面,不能直接搬运到b(b上会有小盘子,大盘子不能在小盘子上面),需要暂时搬到c再搬到b,当n=1的时候不考虑。这是我的理解啊不对不要埋怨我
2015-04-08
L = [75, 92, 59, 68]
sum = 0.0
for name in L:
sum+=name
print sum / 4
sum = 0.0
for name in L:
sum+=name
print sum / 4
2015-04-08