sum = 0
x = 1
while x<=100:
if x%2==1:
sum += x
x = x+1
print sum
# 2500
x = 1
while x<=100:
if x%2==1:
sum += x
x = x+1
print sum
# 2500
2018-05-12
sum = 0
x = 1
n = 1
while True:
sum=sum+(x+1)**n
n=n+1
if n>19:
sum=sum+1
break
print (sum)
只有我一个人会这样写吗?
我把最后一次的执行用来加第一项。
x = 1
n = 1
while True:
sum=sum+(x+1)**n
n=n+1
if n>19:
sum=sum+1
break
print (sum)
只有我一个人会这样写吗?
我把最后一次的执行用来加第一项。
2018-05-12
for x in range(0,10):
for y in range(0,10):
if x < y:
print(str(x)+str(y))
for y in range(0,10):
if x < y:
print(str(x)+str(y))
2018-05-11
tuple 指向不变, 指向不变
tuple = ('a','b',['A', 'B'])
tuple = ('a','b',['A', 'B'])
2018-05-11
for x in ['1','2','3','4','5','6','7','8','9','0' ]:
for y in [ '1','2','3','4','5','6','7','8','9','0' ]:
if x<y:
print x+y
for y in [ '1','2','3','4','5','6','7','8','9','0' ]:
if x<y:
print x+y
2018-05-11
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x*=2
n+=1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+x
x*=2
n+=1
if n>20:
break
print sum
2018-05-11
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=x*2
n=n+1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+x
x=x*2
n=n+1
if n>20:
break
print sum
2018-05-11