def square_of_sum(L):
sum = 0
for i in L:
q = i*i
sum += q
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:
q = i*i
sum += q
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2016-01-22
(已通过)正确答案:
print 'hello,python'
print 'hello,','python'
print 'hello,python'
print 'hello,','python'
2016-01-21
L = ['Adam', 'Lisa', 'Bart']
(L[0],L[2])=(L[2],L[0])
print L
(L[0],L[2])=(L[2],L[0])
print L
2016-01-21
sum = 0
x = 1
while x <= 100:
if x / 2 == 0:
sum = sum +x
elif
print x
print sum
x = 1
while x <= 100:
if x / 2 == 0:
sum = sum +x
elif
print x
print sum
2016-01-21
坑爹,dict.iterkeys(),dict.iteritems(),dict.itervalues()方法在python3中都不再支持
2016-01-21
sum = 0
x = 0
while True:
x += 1
if x > 100:
break
elif x%2 != 0:
sum += x
else:
continue
print sum
x = 0
while True:
x += 1
if x > 100:
break
elif x%2 != 0:
sum += x
else:
continue
print sum
2016-01-21
s='Python was started in 1989 by \"Guido\".\nPython is free and easy to learn.'
print s
print s
2016-01-21
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+y
for y in ['0','1','2','3','4','5','6','7','8','9']:
if x < y :
print x+y
2016-01-21
sum = 0
x = 1
n = 1
while True:
sum += 2**(x-1)
x += 1
n += 1
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum += 2**(x-1)
x += 1
n += 1
if n > 20:
break
print sum
2016-01-21