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])
2015-12-28
def square_of_sum(L):
sum = 0
for i in L:
sum = 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 = sum + (i*i)
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-12-28
L = [75, 92, 59, 68]
sum = 0.0
for a in L:
sum = sum + a
print sum/4
sum = 0.0
for a in L:
sum = sum + a
print sum/4
2015-12-28
>>> L=['adam','lisa','bart']
>>> L.insert(2,'paui')
>>> print L
['adam', 'lisa', 'paui', 'bart']
本地测试是可以的,但是这个不行!!
>>> L.insert(2,'paui')
>>> print L
['adam', 'lisa', 'paui', 'bart']
本地测试是可以的,但是这个不行!!
2015-12-27
这一题让我震惊了,在电脑上能运行,在这里居然出错了,多了一个u在电脑上也没有报错啊( ⊙ o ⊙ )!
另外指定编码也可以在最开始这样声明 #coding=utf-8
另外指定编码也可以在最开始这样声明 #coding=utf-8
2015-12-26
sum = 0
x = -1
while True:
x = x + 2
if x > 100:
break
sum=sum+x
print sum
x = -1
while True:
x = x + 2
if x > 100:
break
sum=sum+x
print sum
2015-12-26
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
把里面的所以转义字符和换行符去掉就可以了
Whether it's nobler in the mind to suffer.'''
把里面的所以转义字符和换行符去掉就可以了
2015-12-26