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]
2019-03-13
L = ['1','2','3','4','5','6','7','8','9']
for x in L:
for y in L:
if y > x:
print x + y
for x in L:
for y in L:
if y > x:
print x + y
2019-03-13
sum = 0
x = 1
n = 1
while True:
x = x*2
n+=1
if n==21:
sum = x - 1
break
print sum
x = 1
n = 1
while True:
x = x*2
n+=1
if n==21:
sum = x - 1
break
print sum
2019-03-13
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(-1)
L.pop(-1)
print L
L.pop(-1)
L.pop(-1)
print L
2019-03-13
s = 'Python was started in 1989 by "Guido".\n\tPython is free and easy to learn.'
print s
print s
2019-03-13
L = ['Adam', 'Lisa', 'Bart', 'Paul']
R = range(1,5)
X = zip(R,L)
for index, name in X:
print index, '-', name
我觉得我这样写比他这种要容易理解多了。
R = range(1,5)
X = zip(R,L)
for index, name in X:
print index, '-', name
我觉得我这样写比他这种要容易理解多了。
print [x+y+z for x in '123456789' for y in'0123456789'for z in '123456789'if x==z]
2019-03-13
print [x+y+x for x in '123456789' for y in'0123456789']
2019-03-13