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
已采纳回答 / AaronYun
<...图片...>貌似你拼写错了。另外,这个函数只对正数求平方根,可能你有时候对有时候错是这个原因吧,加上对b**2-4ac的判断就好了。<...图片...>就这样,我初学者,欢迎交流。
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