python编程从入门到实践课后题答案-python编程从入门到实践第三章习题答案

3.1-3.2names = ['zhichao' , 'yujie' , 'yifei']

for name in names:

print( name.title() + " , good night.")3.3transportation = ['car' , 'walk', 'bicycle' , 'motorcycle']

for elem in transportation :

print( "I would like to own a Honda motorcycle " + elem )3.4-3.7#3.4部分people = ['宙斯' , '赫拉' , '雅典娜' , '阿芙洛蒂忒' ]for person in people :

print( person + " , I want to have a dinner with you." )

#3.5部分

unable = '宙斯'

new_one = '海伦'

print( unable + " can't participate in." )

print ( 20 * "*")unable = '宙斯'

new_one = '海伦'

people.remove( unable )#3.6部分

people.append( new_one )

people.insert( 0,'阿波罗')

people.insert( 3,'阿瑞斯' )

for person in people :

print( person + " , I want to have a dinner with you." )print ( 20 * "*")

#3.7部分while len( people ) > 2 :

people.pop()

for person in people :

print( person + " , I want to have a dinner with you." )i = len(people) -1

while i > 0 :

del people[i]

i = len( people )-1

3.8place = ['England' , "Greece" , 'America' , 'France']

print( place )

print( sorted( place ) )

print( place )

print( sorted( place , reverse = True ) )

print( place )

place.reverse()

print( place )

place.reverse()

print( place )

place.sort()

print( place )

place.sort( reverse = True )

print( place )

3.9这个已经在3.4-3.7的代码块中展示过

3.10-3.11 略

你可能感兴趣的:(python编程从入门到实践课后题答案-python编程从入门到实践第三章习题答案)