L = ['Adam', 'Lisa', 'Bart', 'Paul']
for index, name in enumerate(L):
print int(index)+1, '-', name
for index, name in enumerate(L):
print int(index)+1, '-', name
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for name,score in s:
print name,':',score
# 其实用两个变量也可以吧...
for name,score in s:
print name,':',score
# 其实用两个变量也可以吧...
2015-05-26
L = ['Adam', 'Lisa', 'Bart']
L[0]='Bart'
L[2]='Adam'
print L
L[0]='Bart'
L[2]='Adam'
print L
2015-05-25
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
print L
L.pop(2)
print L
L.pop(2)
print L
L.pop(2)
print L
2015-05-25
for x in range(1,10):
for y in range(10):
if x<y:
print x*10+y
for y in range(10):
if x<y:
print x*10+y
2015-05-25
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2 == 0:
continue
sum += x
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2 == 0:
continue
sum += x
print sum
2015-05-25
sum = 0
x = 1
n = 1
while True:
sum += x
x *= 2
n += 1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum += x
x *= 2
n += 1
if n>20:
break
print sum
2015-05-25
def move(n, a, b, c):
while n>0:
if n==1:
print a+'-->'+c
else:
print a+'-->'+b
return move(n-1,a,b,c)
move(4, 'A', 'B', 'C')
while n>0:
if n==1:
print a+'-->'+c
else:
print a+'-->'+b
return move(n-1,a,b,c)
move(4, 'A', 'B', 'C')
2015-05-25
sum = 0
x = 1
while x < 100:
sum += x
x += 2
print sum
x = 1
while x < 100:
sum += x
x += 2
print sum
2015-05-25