def square_of_sum(L):
return sum([x*x for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
return sum([x*x for x in L])
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-08-24
代码检查有缺陷,如果只输入'adam','bart'就会成功,与题目意思不符
2015-08-24
已采纳回答 / 小猫过河
因为错了,所以不能通过。x1=(-b + math.sqrt( b * b - 4 * a * c ))/ 2 * a x2=(-b - math.sqrt( b * b - 4 * a * c ))/ 2 * a一元二次方程是,除2a不是,除2乘a。所以2*a加一个括号就对哦。
2015-08-24
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-08-23
sum = 0
x = 1
n = 1
while True:
if (n > 20):
break
sum += x
x *= 2
n += 1
print sum
x = 1
n = 1
while True:
if (n > 20):
break
sum += x
x *= 2
n += 1
print sum
2015-08-23
sum = 0
x = 1
while x <= 100:
if(x % 2 != 0):
sum += x
x +=1
print sum
x = 1
while x <= 100:
if(x % 2 != 0):
sum += x
x +=1
print sum
2015-08-23
s=[100*x+10*y+z for x in range(1,10) for y in range(0,10) for z in range(1,10) if x==z]
print s
print s
2015-08-23
if score<60:
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.iteritems()]
return '<tr><td>%s</td><td style="color:red">%s</td></tr>' % (name, score)
else:
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.iteritems()]
2015-08-23