sum = 0
x = 1
n = 1
while True:
if n > 20:
break
sum += x
x = x*2
n +=1
print sum
x = 1
n = 1
while True:
if n > 20:
break
sum += x
x = x*2
n +=1
print sum
2015-04-29
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print k,':',v
print 'average', ':',sum/len(d)
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print k,':',v
print 'average', ':',sum/len(d)
2015-04-28
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for i in d.itervalues():
sum=sum+i
print sum/len(d)
sum = 0.0
for i in d.itervalues():
sum=sum+i
print sum/len(d)
2015-04-28
最赞回答 / DanDanHang
Python是按照缩进来确定代码块的,你在CMD里头的代码缩进不对,所以就出现了错误。<...code...>注意观察下我这种写法和你在CMD中的不同。
2015-04-28
最新回答 / 坏坏程序员
for x in range(9): for y in range(9): if x < y: print x*10+y你那个是错误的,一眼就看出来了,你X都101 了 乘10 那是多少了~~~~ 你算算吧
2015-04-27
sum = 0
x = 1
n = 1
while True:
x=x+2**n
n=n+1
sum=sum+x
if n>=19:
break
print sum
x = 1
n = 1
while True:
x=x+2**n
n=n+1
sum=sum+x
if n>=19:
break
print sum
2015-04-27