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-03-23
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print "%s: %s" %x
for x in s:
print "%s: %s" %x
2015-03-23
age = 20
if age < 6:
print 'kid'
elif age >= 18:
print 'adult'
else:
print 'teenager'
if age < 6:
print 'kid'
elif age >= 18:
print 'adult'
else:
print 'teenager'
2015-03-23
这个模拟器并不能完全模拟Windows的命令行模式,当我尝试输入多行字符串时,输入第一行,按下回车,模拟器会一直提示错误,知道我把字符串全部写完之后才显示出字符串,而Windows命令行会在每次按下回车后显示省略号“...”,很不习惯。
2015-03-23