【第三周】第六章全部习题
2018-03-21 21:48
190 查看
6-1人
6-2喜欢的数字
6-3 词汇表
6-4词汇表2
6-5河流
6-6调查
6-7人
6-8宠物
6-9喜欢的地方
6-10喜欢的数字
6-11城市
6-12扩展
people = { 'first_name':'Lucy', 'last_name': 'Zheng' , 'age': 20 , 'city': 'Guangzhou'} print (people)
6-2喜欢的数字
num = {'Lucy': 17 , 'Peppa': 2 , 'George': 4 , 'LittlePig': 7} print (num)
6-3 词汇表
vo = { 'del': 'delete sth', '.lower()' : 'the lower case of the string', '.upper()' : 'the upper case of the string', 'if' : 'to judge', 'len' : 'the length of sth' } for key in vo.keys(): print(key+' : '+vo[key])
6-4词汇表2
vo = { 'del': 'delete sth', '.lower()' : 'the lower case of the string', '.upper()' : 'the upper case of the string', 'if' : 'to judge', 'len' : 'the length of sth', 'print': 'print sth on the screen', '.key()': 'find the keys of the vocabulary', '.items' : 'find the items of the vocabulary', '.values()' : 'find the values of the vocabulary', 'else' : 'to judge' } for key,value in vo.items(): print(key+' : '+value)
6-5河流
river = { 'nile' : 'Egypt', 'Times' : 'England', 'The Changjiang river' : 'China' } for key,value in river.items(): print('The '+ key.title() + ' runs through ' + value) for key in river.keys(): print(key) for value in river.values(): print(value)
6-6调查
people = ['Peppa','George','Bob'] serve = {'Bob':'Have done'} for peo in people: if peo in serve.keys(): print(peo + ',thank you for attending our serving.') else: print(peo + ',please attend our serving.')
6-7人
people1 = { 'first_name':'Lucy', 'last_name': 'Zheng' , 'age': 20 , 'city': 'Guangzhou'} people2 = { 'first_name':'Jair', 'last_name': 'Zhu' , 'age': 20 , 'city': 'Guangzhou'} people3 = { 'first_name':'David', 'last_name': 'Li' , 'age': 19 , 'city': 'Guangzhou'} people = [people1,people2,people3] for pe in people: print(pe)
6-8宠物
Candy = {'type': 'cat' , 'owner' : 'Bob'} Peppa = {'type': 'pig' , 'owner' : 'Kevin'} Suxy = {'type': 'sheep' , 'owner' : 'Stuart'} pets = [Candy,Peppa,Suxy] for pet in pets: print(pet)
6-9喜欢的地方
favourite_places = { 'Bob' : ['Beijing','Shanghai','Guangzhou'], 'Kevin' : ['Chongqing','Xian','Harbin'], 'Stuart' : ['Chengdu' ,'Guilin' ,'Xiamen'] } for key,value in favourite_places.items(): print (key + ' ' , value)
6-10喜欢的数字
num = { 'Lucy': [17,18,19], 'Peppa': [2,3,4], 'George': [4,5,6], 'LittlePig': [7,8,9] } for key,value in num.items(): print(key,value)
6-11城市
cities = { 'Beijing': { 'Country':'China','population':21730000,'fact':'the center of politics'}, 'Shanghai': { 'Country':'China','population':24200000,'fact':'the center of economy'}, 'Guangzhou' : {'Country':'China','population':14490000,'fact':'the center of exportation'}, } for key,value in cities.items(): print (key,' ',value)
6-12扩展
favourite_languages = { 'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'python', } favourite_languages['Bob'] = 'php' for key,value in favourite_languages.items(): print (key,' ',value)
相关文章推荐
- 【第三周】第五章全部习题
- 【TIJ4】第六章全部习题【习题未完成】
- Perl语言入门-第六章-哈希-习题
- 第六章习题
- 零基础学java语言-中国大学慕课-翁凯老师-第六章习题-数单词长度
- C++Primer(第六章课后习题)(程序题源代码)
- 《C++ Primer》第五版课后习题解答_第六章(1)(01-07)
- 《C++ Primer》第五版课后习题解答_第六章(4)(27-35)
- How to think like a Computer Scientist: 课后习题第六章 1-5
- 算法竞赛入门经典(第二版)-刘汝佳-第六章 数据结构基础 习题(12/14)
- C++Primer第五版 第六章习题答案(51~56)
- 【第二周】第三章全部习题3-1~3-11
- 关于《Java读书笔记》第六章课后习题选择题总结与疑问
- Learning Perl 第六章习题第一题
- How to think like a Computer Scientist: 课后习题第六章 6-12
- 编程珠玑--------第六章习题笔记
- 【TIJ4】第三章全部习题
- 第三周作业第六章
- 作业7——第六章习题选做
- python 核心编程 第六章 习题16 矩阵加法和乘法