print L[0:10]
print L[2::3]
print L[4:50:5]
or
print L[0:10]
print L[2:100:3]
print L[4:50:5]
print L[2::3]
print L[4:50:5]
or
print L[0:10]
print L[2:100:3]
print L[4:50:5]
2019-06-17
安装python时,向导已经提醒是否要把Python.exe加入到path了,结果这视频直接忽略 默认了否...然后自己手动加... 真是天才
2019-06-16
已采纳回答 / 慕用9557919
没换之前,sum = sum+x,x=x+2 x is 1,sum加了一个1换之后,x=x+2,sum=sum+x x is 3,sum直接加3,少了一个1
2019-06-15
x1 = 1
d = 3
n = 100
x100 = x1 + (n - 1) * d #第一百项 = 第一项 + (个数) * 递增的数值
s = (x1 + x100) * n / 2 #s = (第一项 + 第一百项) * 首末相加为一组,组数
print s
d = 3
n = 100
x100 = x1 + (n - 1) * d #第一百项 = 第一项 + (个数) * 递增的数值
s = (x1 + x100) * n / 2 #s = (第一项 + 第一百项) * 首末相加为一组,组数
print s
2019-06-15
sum = 0
n = 1
while True:
if n>20:
break
sum+=1<<(n-1)
n=n+1
print sum
n = 1
while True:
if n>20:
break
sum+=1<<(n-1)
n=n+1
print sum
2019-06-15
sum = 0
n = 1
while True:
if n<=20:
sum+=1<<(n-1)
n=n+1
else:
break
print sum
n = 1
while True:
if n<=20:
sum+=1<<(n-1)
n=n+1
else:
break
print sum
2019-06-15
已采纳回答 / 慕圣4564532
按位异或逻辑运算符,要转二进制,按位判断异或比如 1^2 就是 0001 ^ 0010 = 0011 就是32^2 就是 0010 ^ 0010 = 0000 就是03^2 就是 0011 ^ 0010 = 0001 就是1
2019-06-14
def square_of_sum(L):
return sum(i * i for i in L)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
return sum(i * i for i in L)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-06-14
def square_of_sum(L):
sum=0
for i in L:
sum+=i*i
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum=0
for i in L:
sum+=i*i
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-06-14
for x in[ '1','2','3','4','5','6','7','8','9']:
for y in[ '0','1','2','3','4','5','6','7','8','9']:
if x<y:
print x+y
for y in[ '0','1','2','3','4','5','6','7','8','9']:
if x<y:
print x+y
2019-06-14