x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = n*(x1+x100)/2
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = n*(x1+x100)/2
print s
2018-08-02
for x in ['1','2','3','4','5','6','7','8','9' ]:
for y in [ '2','3','4','5','6','7','8','9' ]:
if x>=y:
continue
print x+y
for y in [ '2','3','4','5','6','7','8','9' ]:
if x>=y:
continue
print x+y
2018-08-02
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=pow(2,n)
n=n+1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+x
x=pow(2,n)
n=n+1
if n>20:
break
print sum
2018-08-02
发现一个BUG
sum = 0
x = 1
while True:
sum=sum+x
x = x + 2
if x > 100:
break
print sum
sum = 0
x = 1
while True:
sum=sum+x
x = x + 2
if x > 100:
break
print sum
2018-08-02
第一个数为2.5,是浮点型,后面两个数的运算是整型,得出来的数就算是浮点型也会自动转为整型——也就是直接抹掉小数点后的。所以得出的结果是4.5而不是5.0
2018-08-01
等差数列,每个数相隔都是一样的,可以把它想象成一个侧面看是三角形台阶,从第一个台阶到第一百个,然后把它反过来放在上面就是一个长方形,收尾相加乘上总共一百个台阶得出的结果是两个的,再除二就可以了。
2018-08-01
sum = 0
x = 1
n = 1
while True:
sum+= x
x+= x
n+= 1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum+= x
x+= x
n+= 1
if n>20:
break
print sum
2018-08-01
我想说,按照题的要求,不应该是这样打印吗:
A --> B
A --> B
A --> B
A --> C
B --> C
A --> B
A --> B
A --> B
A --> C
B --> C
2018-08-01
def move(n, a, b, c):
if n ==1:
print a, '-->', c
print b, '-->', c
return
else:
print a, '-->', b
move(n-1, a, b, c)
move(4, 'A', 'B', 'C')
if n ==1:
print a, '-->', c
print b, '-->', c
return
else:
print a, '-->', b
move(n-1, a, b, c)
move(4, 'A', 'B', 'C')
2018-08-01