6-7

6–7

info_1 = {'first_name':'cjoke',
    'last_name':'hu',
    'age':'24',
    'city':'hangzhou',
    }
info_2 = {'first_name':'jen',
    'last_name':'pete',
    }
info_3 = {'first_name':'jay',
    'last_name':'key'}
infos = [info_1,info_2,info_3]
for info in infos:
    print(info)


6-8

pet_1 = {'Pet type':'dog_0',
    'master':'cjoke_0',
    } 
pet_2 = {'Pet type':'dog_1',
    'master':'cjoke_1',}
pet_3 = {'Pet type':'dog_2',
    'master':'cjoke_2',}
pets = [pet_1,pet_2,pet_3]
for pet in pets:
    print(pet)
#6-9和6-10 差不多(大概)
favorite_places = {'hu':['hubei','beijing'],
    'wang':['fujian','guangdong'],
    'zhu':['hongkong','xizang']}
for name,places in favorite_places.items():
    print(name.title() + '喜欢的地方是:')
    for place in places: 
    #这个循环就是遍历值里面的列表
        print('\t     ' + place.title())

cities = {
    'hangzhou':{
        'country':'china',
        'population':'1036万人',
        'fact':'电子商务中心'
        },

    'jinghzou':{
        'country':'china',
        'population':'537.16万人',
        'fact':'刘备借荆州'},

    'wuhan':{
        'country':'china',
        'population':'1121.2万人',
        'fact':'“九省通衢'},
    
    }
for city,infos in cities.items():
    print(city.title() + '这个城市的信息如下:')
    print('这个城市属于:' + infos['country'])
    print('这个城市人口有:' + infos['population'])
    print('这个城市的信息为:' + infos['fact']) 

这些都是作业都和教材里面的案例都差不多,我也不知道是否正确,如有不对的大家可以指出来,道阻且长,行则将至

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值