您的位置:首页 > 编程语言 > Python开发

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

2018-03-12 23:27 645 查看
3.1-3.2
names = ['zhichao' , 'yujie' , 'yifei']

for name in names:
print( name.title() + " , good night.")
3.3
transportation = ['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.8
place = ['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
相关文章推荐