L = [75, 92, 59, 68]
sum = 0.0
for x in L:
sum = sum + x
print sum / 4
可能是我基础不好,可以解释一下为什么是 sum = sum + x 。 + x代表什么
sum = 0.0
for x in L:
sum = sum + x
print sum / 4
可能是我基础不好,可以解释一下为什么是 sum = sum + x 。 + x代表什么
2018-12-13
这题目的描述和实际的这游戏规则也差太多了吧,不知道的还以为把n-1个圆盘依次移动到B,然后把最后一个移动到C,在从B依次移动圆盘到C
2018-12-13
sum = 0
x = 1
n = 1
while True:
sum=sum+n
n=2^x
x=x+1
if x >=20
break
print sum
x = 1
n = 1
while True:
sum=sum+n
n=2^x
x=x+1
if x >=20
break
print sum
2018-12-12
# -*- coding: utf-8 -*-
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。
'''
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。
'''
2018-12-12
x1 = 1
d = 3
n = 100
x100 = x1 + (n - 1) * 3;
s = (x1 + x100) * n / 2;
print s
d = 3
n = 100
x100 = x1 + (n - 1) * 3;
s = (x1 + x100) * n / 2;
print s
2018-12-12
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-12-10
print [int(a + b + c) for a in '123456789' for b in '0123456789' for c in '123456789' if a==c]
2018-12-08
def greet(x='world'):
#print 'Hello, ',x,'.'
print 'Hello,%s.'%(x)
greet()
greet('Bart')
#print 'Hello, ',x,'.'
print 'Hello,%s.'%(x)
greet()
greet('Bart')
2018-12-05