sum = 0
n = 0
while True:
sum = sum + 2**n
n = n + 1
if n > 19:
break
print sum
n = 0
while True:
sum = sum + 2**n
n = n + 1
if n > 19:
break
print sum
2015-08-03
L = ['Adam', 'Lisa', 'Bart']
L.insert(-1,'Paul')
print L
L.insert(-1,'Paul')
print L
2015-08-03
#先写2个盘子的情况,然后交换a,b(重要)的地位,仅两步,之前怎么就想不通呢
def move(num,a,b,c):
if num == 1:
print a,'-->',c
return True
print a,'-->',b
print a,'-->',c
move(num-1,b,a,c)
move(2,'A','B','C')
def move(num,a,b,c):
if num == 1:
print a,'-->',c
return True
print a,'-->',b
print a,'-->',c
move(num-1,b,a,c)
move(2,'A','B','C')
2015-08-03
正确答案
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L[-1]
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L[-1]
2015-08-02
修复:
age = 8
if age >= 18:
print 'adult'
elif age >= 6:
print 'teenager'
else:
print 'kid'
age = 8
if age >= 18:
print 'adult'
elif age >= 6:
print 'teenager'
else:
print 'kid'
2015-08-02
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if not x%2==0:
sum=sum+x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if not x%2==0:
sum=sum+x
print sum
2015-08-02
sum = 0
x = 1
while True:
x = x + 1
if x > 100:
break
if not x%2==0:
sum=sum+x
print sum
x = 1
while True:
x = x + 1
if x > 100:
break
if not x%2==0:
sum=sum+x
print sum
2015-08-02