最新回答 / 慕码人4117838
第一个错误是 n=20是赋值语句,不能用作条件作为判断。第二是就算n==20时也是错的,因为只加了前19项的和,没加第20项,所以要n>20才可以。
2019-07-18
最赞回答 / 华青少年
n=[[i+10*k+100*n for i in range(1,2) for k in range(0,j) for n in range(1,2) if i==n] for j in range(1,11)] for m in n: print(m,'\n')
2019-07-17
print (r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
Whether it's nobler in the mind to suffer.''')
2019-07-16
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
print s
print s
2019-07-16
x1 = 1
d = 3
n = 100
x100 = (n-1)*d+x1
s = (x1+x100)*n/2
print s
x1 = 1
d = 3
n = 100
d = 3
n = 100
x100 = (n-1)*d+x1
s = (x1+x100)*n/2
print s
x1 = 1
d = 3
n = 100
2019-07-16
print("hello,python.")
print("hello,"+"python.")
print("hello,"+"python.")
2019-07-16
已采纳回答 / qq_慕姐3168913
因为你的sum = sum +x 在x%2==0:下面,相当于你单纯的循环了一遍x=1,到x=99之间的奇数,等于偶数就跳出然后返回了开始定义的sum = 0,你的sum没有参与到你定义的循环(continue就退出了,sum = sum +x也没计算到,你如果把continue去掉就可以计算偶数的和)
2019-07-16