s = 'Python was started in 1989 by "Guido".Python is free and easy to learn.'
print s #答案把python前面的空格去掉就可以了!
print s #答案把python前面的空格去掉就可以了!
2018-04-20
L = ['Adam', 'Lisa', 'Bart']
L.insert(0,L.pop())
# L.pop() = Bart 所以是将Bart 提到第一,并且删除最后一个,也就是Bart
# [Bart , Adam , Lisa]
L.insert(1,L.pop())
# 同理,将 Lisa 提到中间,并且删掉,Lisa
print L
L.insert(0,L.pop())
# L.pop() = Bart 所以是将Bart 提到第一,并且删除最后一个,也就是Bart
# [Bart , Adam , Lisa]
L.insert(1,L.pop())
# 同理,将 Lisa 提到中间,并且删掉,Lisa
print L
2018-04-20
a or 'world' # ==> a
b or 'world' #==>b
b or 'world' #==>b
2018-04-20
def average(*args):
sum=0.0
a=0
for i in args:
sum=sum+i
a=a+1
if a==0 :
return sum/1
return sum/a
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum=0.0
a=0
for i in args:
sum=sum+i
a=a+1
if a==0 :
return sum/1
return sum/a
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-04-20
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
2018-04-20
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for v in d.values():
sum+=v
sum=sum/len(d.values())
print sum
sum = 0.0
for v in d.values():
sum+=v
sum=sum/len(d.values())
print sum
2018-04-20
L = ['Adam', 'Lisa', 'Bart']
L.insert(0,L.pop())
L.append(L.pop(1))
print L
L.insert(0,L.pop())
L.append(L.pop(1))
print L
2018-04-20