def move(n, a, b, c):
if n==0 :
return;
move(n-1,a,c,b)
print a,'-->',c
move(n-1,b,a,c)
move(4, 'a', 'b', 'c')
if n==0 :
return;
move(n-1,a,c,b)
print a,'-->',c
move(n-1,b,a,c)
move(4, 'a', 'b', 'c')
2016-04-10
s = " Python was started in 1989 by \"Guido\". \n Python is free and easy to learn.";
print s;
print s;
2016-04-10
最新回答 / 清波
是这样的Python2.x 版本中 的默认编码 是 ASCII ,对应的Python3.x 对默认编码进行了升级 变成了 unicode. 还有建议在Python2.x 中声明 中文或者说所有Unicode 编码 字符串的时候 前面都加上u。因为有的 解释器 对开头的 声明 支持的不友好。另 给出 PEP 文档,针对这个声明 官方文档:https://www.python.org/dev/peps/pep-0263/
2016-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
2016-04-10
系统给的答案对么?
sum=0
x=0
n=0
while True:
sum=sum+x
x=2**n
n=n+1
if n>19:
break
print sum
sum=0
x=0
n=0
while True:
sum=sum+x
x=2**n
n=n+1
if n>19:
break
print sum
2016-04-09
def move(n, a, b, c):
if n==1:
print a,'-->',c
return
else:
move(n-1,a,c,b)
print a,'-->',b
move(1,a,b,c)
print a,'-->',c
move(n-1,b,a,c)
print b,'-->',c
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
return
else:
move(n-1,a,c,b)
print a,'-->',b
move(1,a,b,c)
print a,'-->',c
move(n-1,b,a,c)
print b,'-->',c
move(4, 'A', 'B', 'C')
2016-04-09
已采纳回答 / 霍霍不二
你用的什么编辑器?notepad++么?看提示是因为tab和空格混用,缩进不一样报错的。代码是自己敲的还是复制的呀?缩进是自动生成的么?试一下if下面的两个if前面的空删掉重新敲一下,一般建议都是一个tab,或者四个空格
2016-04-09
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2 != 0:
sum += x
continue
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2 != 0:
sum += x
continue
print sum
2016-04-09
sum = 0
x = 1
n = 1
while True:
if(n>=2):
x *= 2
sum += x
n += 1
if(n>20):
break;
print sum
x = 1
n = 1
while True:
if(n>=2):
x *= 2
sum += x
n += 1
if(n>20):
break;
print sum
2016-04-09
print(45678 + 0x12fd2)
print("Learn Python in imooc")
print(100 < 99)
print(0xff == 255)
print("Learn Python in imooc")
print(100 < 99)
print(0xff == 255)
2016-04-09
#input code
a='hello,'
b='python'
print a,b
print'hello,python'
a='hello,'
b='python'
print a,b
print'hello,python'
2016-04-09