已采纳回答 / qq_慕数据8247156
def move(n, a, b, c): if n ==1: //当n 等于1时才执行,所以这个判断语句执行否,也就是后面的句子 print a, '-->', c return move(n-1, a, c, b) //这里就是if后的句子,再执行move函数,但是n-1,也就是再判断一次n是否等于1,不行就一直重复执行,知道n=1,而这里的b和c的位置互换了,当执行if 里的输出时,实际输出的是c那个位置的b ...
2020-04-17
python 3.7 中 set 格式是:
s = {'A', 'B', 'C'}
print(s)
s = {'A', 'B', 'C'}
print(s)
2020-04-16
def sum(n):
sum = 0
for i in range(1,n+1):
i = i * i
sum = sum + i
return sum
print sum(100)
sum = 0
for i in range(1,n+1):
i = i * i
sum = sum + i
return sum
print sum(100)
2020-04-15
l=[]
for m in range(1,10):
for n in range(0,10):
for j in range(1,10):
if m==j:
l.append(m*100+n*10+j)
print l
for m in range(1,10):
for n in range(0,10):
for j in range(1,10):
if m==j:
l.append(m*100+n*10+j)
print l
2020-04-15
print [m*100+n*10+j for m in range(1,10) for n in range(0,10) for j in range(1,10) if m==j]
2020-04-15
>>> classMate = set(['Adam','Lisa','Paul'])
>>> print(classMate)
{'Adam', 'Lisa', 'Paul'}
>>> print(classMate)
{'Adam', 'Lisa', 'Paul'}
2020-04-15
优先执行age>=6了,要在设置一个上线
if 18 > age >= 6:
print ('teenager')
elif age >= 18:
print ('adult')
就输出了adult
if 18 > age >= 6:
print ('teenager')
elif age >= 18:
print ('adult')
就输出了adult
2020-04-14