sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if (x+1)%2:
continue
sum+=x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if (x+1)%2:
continue
sum+=x
print sum
2020-01-15
sum = 0
x = 1
n = 1
while True:
sum = sum + x
n = n + 1
x = 2 ** (n-1)
if n > 20:
break
print sum 这个用幂运算的结果也成功了。看来要实现一种效果可以有多种代码表达方式
x = 1
n = 1
while True:
sum = sum + x
n = n + 1
x = 2 ** (n-1)
if n > 20:
break
print sum 这个用幂运算的结果也成功了。看来要实现一种效果可以有多种代码表达方式
2020-01-15
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for sorce in d.values():
sum += sorce
end = sum/(len(d))
print '%0.2f' % end
sum = 0.0
for sorce in d.values():
sum += sorce
end = sum/(len(d))
print '%0.2f' % end
2020-01-15
print 45678+0x12fd2
print"learn python in imooc"
print 100<99
print 0xff==255
print"learn python in imooc"
print 100<99
print 0xff==255
2020-01-14
for x in [0,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*10+y)
for y in [0,1,2,3,4,5,6,7,8,9]:
if x<y:
print(x*10+y)
2020-01-09
把break放在后面也可以
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = x*2
n = n+1
if n>20:
break
print sum
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x = x*2
n = n+1
if n>20:
break
print sum
2020-01-05