我要再对慕课说一句 来这的不只有“官人”和“偶吧”,不能这样的,妹子也是可以有敲两行代码的权利的
2015-07-09
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L[2]
print L[0]
print L[1]
print L[2]
print L[2]
2015-07-08
L = []
for i in range(1, 101):
s = i**2
L.append(s)
print sum(L)
for i in range(1, 101):
s = i**2
L.append(s)
print sum(L)
2015-07-08
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for i in L:
if i in s:
s.remove(i)
else:
s.add(i)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for i in L:
if i in s:
s.remove(i)
else:
s.add(i)
print s
2015-07-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print key,':',d[key]
2015-07-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
d['Paul'] = 75
print d
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
d['Paul'] = 75
print d
2015-07-08
for x in range(1, 10):
for y in range(10):
if x < y:
print x * 10 + y
else:
continue
for y in range(10):
if x < y:
print x * 10 + y
else:
continue
2015-07-08
sum = 0
i = 1
x = 1
while True:
sum += x
if i < 20:
x = x * 2
i += 1
else:
break
print sum
i = 1
x = 1
while True:
sum += x
if i < 20:
x = x * 2
i += 1
else:
break
print sum
2015-07-08
sum = 0
x = 1
while x <= 100:
if x % 2 ==1:
sum += x
print sum
x = 1
while x <= 100:
if x % 2 ==1:
sum += x
print sum
2015-07-08
为什么一定要加 r ?其实就这题而言,这个 r 写不写结果都一样吧。因为三引号里面的双引号和单引号本来就不需要转义
2015-07-08
#encoding:utf8
L=['Adam','Lisa','Bart','Paul']
n=0
for i in L:
print "名字为"+i+"的索引为:",L.index(i)
n+=1
L=['Adam','Lisa','Bart','Paul']
n=0
for i in L:
print "名字为"+i+"的索引为:",L.index(i)
n+=1