代码仅供参考。
for x in range(1,10):
for y in range(10):
if x < y:
print x * 10 + y
for x in range(1,10):
for y in range(10):
if x < y:
print x * 10 + y
2015-07-20
def square_of_sum(L):
sum = 0
for l in L:
sum += l*l
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum = 0
for l in L:
sum += l*l
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-07-20
L = []
i = 1
while(i<=100):
L.append(i*i)
i += 1
print sum(L)
i = 1
while(i<=100):
L.append(i*i)
i += 1
print sum(L)
2015-07-20
for x in ['1','2','3','4','5','6','7','8','9']:
for y in ['1','2','3','4','5','6','7','8','9']:
if x < y:
print x + y
for y in ['1','2','3','4','5','6','7','8','9']:
if x < y:
print x + y
2015-07-20
print "Python was started in 1989 by \"Guido\".\nPython is free and easy to learn."
2015-07-19
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k,v in d.iteritems():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
sum = 0.0
for k,v in d.iteritems():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
2015-07-19