《高级编程技术》第三周作业
2018-03-21 23:00
323 查看
5-6 人生的不同阶段:
# -*- coding: utf-8 -*- age = 23 if age < 2: print ('你是婴儿。') elif age < 4: print ('你正蹒跚学步。') elif age < 13: print ('你是儿童。') elif age < 20: print ('你是青少年。') elif age < 65: print ('你是成年人。') else : print ('你是老年人。')5-7 喜欢的水果:
favorite_fruits = ['orange', 'pineapple', 'watermelon'] if 'apple' in favorite_fruits: print ('You really like apple.') if 'banana' in favorite_fruits: print ('You really like banana') if 'orange' in favorite_fruits: print ('You really like orange.') if 'watermelon' in favorite_fruits: print ('You really like watermelon.') if 'grape' in favorite_fruits: print ('You really like grape.')5-10 检查用户名:
current_users = ['Byrant', 'James', 'Durant', 'Harden', 'Curry'] new_users = ['Durant', 'Davis', 'HARDEN', 'Paul', 'Ingram'] for new_user in new_users: if new_user.title() in current_users: print ('Sorry, user name ' + new_user+ ' has been used. Please enter another one.') else : print (new_user+' is a new user name.')< 9288 /pre>6-2喜欢的数字:NBA_Players = {'Byrant':24, 'Jardan':23, 'Iverson':3, 'Duncan':21, "O'Neal":34} for name, number in NBA_Players.items(): print (name + "'s number is "+ str(number))6-5 河流:rivers = {'nile':'egypt', 'yangtze':'china', 'amazon':'brazil'} for river, country in rivers.items(): print ('The ' + river.title() + ' river runs through ' + country.title() + '.') print ('\n') for river in rivers.keys(): print (river.title()) print ('\n') for country in rivers.values(): print (country.title())6-8 宠物:Rocco = {'Breed':'Bulldog' , 'owner':'Klay Tompson'} Wangkeke = {'Breed':'Alaskan Malamute' , 'owner':'Wangsicong'} Dami = {'Breed':'Chinese pastoral cat' , 'owner':'Ms.papi'} pets = [Rocco, Wangkeke, Dami] for pet in pets: print (pet)
相关文章推荐
- 【高级编程技术】第三周作业
- 第三周作业(1)——高级编程技术
- 【高级编程技术】【作业】【第三周】【1】
- 高级编程技术 第三周作业
- 高级编程技术第三周平时作业
- 高级编程技术作业第三周 第五章,第六章课后练习
- 高级编程技术第三周平时作业(2)
- 第三周作业(2)——高级编程技术
- 高级编程技术 Python 第三周作业
- 高级编程技术 第三周作业
- 【高级编程技术】【作业】【第三周】【2】
- 学习总结|Linux内核分析 第三周作业 - 网易云课堂
- 第三周作业二(读程序)
- 第三周作业二
- 第三周作业2
- 第三周作业2
- 高级编程技术第一周平时作业(2)
- 第三周作业:Visual Studio 2013
- 第三周作业(三)