L = []
for x in range(1,10):
for y in range(10):
for z in range(1,10):
if(x == z):
L.append(100*x + 10*y +z)
print L
for x in range(1,10):
for y in range(10):
for z in range(1,10):
if(x == z):
L.append(100*x + 10*y +z)
print L
2015-06-10
被自己蠢哭了,写的代码完全是正确的,最后没办法通过。原因是: print a, '-->', c
这里的剪头是两个减号!!!
这里的剪头是两个减号!!!
2015-06-10
print [m+n*10+j*100 for m in range(1,10) for n in range(0,10) for j in range(0,10) if m==j]
2015-06-09
def square_of_sum(L):
s = 0
n = 1
for x in L:
s = s + x*x
n = n + 1
while n > len(L):
return s
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
s = 0
n = 1
for x in L:
s = s + x*x
n = n + 1
while n > len(L):
return s
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-06-09
L = []
x = 1
while x<101:
L.append(x*x)
x = x + 1
print sum(L)
x = 1
while x<101:
L.append(x*x)
x = x + 1
print sum(L)
2015-06-09
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
2015-06-09
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0],":",x[1]
for x in s:
print x[0],":",x[1]
2015-06-09
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k,":",d.get(k)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k,":",d.get(k)
2015-06-08
# -*- coding: utf-8 -*-
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
print u'您的姓名是:',d.get(input)
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
print u'您的姓名是:',d.get(input)
2015-06-08
# -*- coding: utf-8 -*-
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart'
}
2015-06-08