s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for l in L:
if l in s:
s.remove(l)
else:
s.add(l)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for l in L:
if l in s:
s.remove(l)
else:
s.add(l)
print s
2015-08-25
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-08-25
for x in range(1, 9):
for y in range(1, 10):
if x < y:
print x * 10 + y
for y in range(1, 10):
if x < y:
print x * 10 + y
2015-08-25
我的错误代码:
def greet(a,b='Hello python'):
if a==null:
print 'Hello world.'
else:
print 'Hello, xxx'
greet()
greet('Bart')
def greet(a,b='Hello python'):
if a==null:
print 'Hello world.'
else:
print 'Hello, xxx'
greet()
greet('Bart')
2015-08-25
print [x*100+y*10+z for x in range(1,10) for y in range(0,10) for z in range(0,10) if x==z]
2015-08-24
for k, v in d.iteritems():
sum = sum + v
print k+':',v
print 'average'+ ':',sum/len(d)
sum = sum + v
print k+':',v
print 'average'+ ':',sum/len(d)
2015-08-24