def firstCharUpper(s):
return s[:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-05-19
L = ['Adam', 'Lisa', 'Bart']
L[0],L[-1] = L[-1],L[0]
print L
L[0],L[-1] = L[-1],L[0]
print L
2015-05-19
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for score in d.itervalues():
sum += score
print (sum + 0.0) / len(d)
sum = 0.0
for score in d.itervalues():
sum += score
print (sum + 0.0) / len(d)
2015-05-19
L = ['Adam', 'Lisa', 'Bart']
L.insert(2,'Paul')
print L
L.insert(2,'Paul')
print L
2015-05-19
#将list换成tuple.
#tuple中有list时,修改list的值是修改list的指向,并没有修改tuple的指向,所以tuple是“不变”的,但修改了list的值,看起来像是"变了"。
#tuple中有list时,修改list的值是修改list的指向,并没有修改tuple的指向,所以tuple是“不变”的,但修改了list的值,看起来像是"变了"。
2015-05-18