sum = 0
x = 0
while True:
x = x + 1
if x % 2 == 0:
continue
if x > 100:
break
sum = sum + x
print sum
x = 0
while True:
x = x + 1
if x % 2 == 0:
continue
if x > 100:
break
sum = sum + x
print sum
2019-07-30
最赞回答 / qq_慕运维2062768
传入函数的数全是整数的话,算平均数 直接相除,如果有小数,python会把小数直接省掉,而乘一个1.0则整数与浮点数相乘结果为浮点数,这样结果就显示出小数了
2019-07-30
最新回答 / 慕妹9356074
L.insert(0, 'Paul') 的意思是,'Paul'将被添加到索引为 0 的位置上(也就是第一个),而原来索引为 0 的Adam同学,以及后面的所有同学,都自动向后移动一位
2019-07-30
def move(n, a, b, c):
if n==1:
print a,'-->',c
return
move (n-1, a, c, b)
move (1, a, b, c)
move (n-1, b, a, c)
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
return
move (n-1, a, c, b)
move (1, a, b, c)
move (n-1, b, a, c)
move(4, 'A', 'B', 'C')
2019-07-30
最新回答 / 起个名字过不了
是的ur是你没写coding:utf-8并且有很多需要转义的字符的情况下用的比如(coding:utf-8)'There is a magical language called \"中文\".'可以变成 ur'There is a magical language called "中文".'
2019-07-30
def square_of_sum(L):
a = 0
n = 0
for x in L:
while len(L)>n:
a = L[n]*L[n] + a
n = n+1
else:
return a
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
a = 0
n = 0
for x in L:
while len(L)>n:
a = L[n]*L[n] + a
n = n+1
else:
return a
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-07-30