d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:', d.get('Adam')
print 'Lisa:', d.get('Lisa')
print 'Bart:', d.get('Bart')
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:', d.get('Adam')
print 'Lisa:', d.get('Lisa')
print 'Bart:', d.get('Bart')
2016-04-30
这样子打也是妥妥的
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59,
}
d.insert(2,'Paul':75)
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59,
}
d.insert(2,'Paul':75)
2016-04-30
for x in range(1,10):
for y in range(0,10):
if x < y:
print '{high}{low}'.format(high = x, low = y)
for y in range(0,10):
if x < y:
print '{high}{low}'.format(high = x, low = y)
2016-04-29
sum = 0
x = 0
n = 1
while True:
sum += 2 ** x
x += 1
if n >= 20:
break
n += 1
print sum
x = 0
n = 1
while True:
sum += 2 ** x
x += 1
if n >= 20:
break
n += 1
print sum
2016-04-29
s="Python was started in 1989 by \"Guido\".\n Python is free and easy to learn."
print s
print 'Python was started in 1989 by "Guido".'
print 'Python is free and easy to learn.'
print "Python was started in 1989 by \"Guido\"."
print "Python is free and easy to learn."
print s
print 'Python was started in 1989 by "Guido".'
print 'Python is free and easy to learn.'
print "Python was started in 1989 by \"Guido\"."
print "Python is free and easy to learn."
2016-04-29
help(list.insert)
Help on method_descriptor:
insert(...)
L.insert(index, object) -- insert object before index
将元素添加到索引前
Help on method_descriptor:
insert(...)
L.insert(index, object) -- insert object before index
将元素添加到索引前
2016-04-29
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print '%s:%d'%(k,v)
print 'average', ':', sum/len(d)
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print '%s:%d'%(k,v)
print 'average', ':', sum/len(d)
2016-04-29