Python Basic Dictionary Exercises

Source: Internet
Author: User

Exercise 1:
info = [
{' wangming ':
{
' money ': 1111,
' car ': [' BMO ', ' BSJ '],
' info ': {
' phone ': 1511111,
' age ':
}

},
{
' Lilei ':
{
' money ': 99999,
' car ': [' BBB ', ' CCC '],
' house ': {
' Chaoyang ': 1,
' Qinhuangdao ': 3
}

}
}
]
#王明增加一辆车
#info里加一个key
#秦皇岛加2
#给lilei加一个性别
Answer:
#王明增加一辆车
info[0][' wangming ' [' Car '].append (' cars ')
#info里加一个key
info[0][' wangming ' [' Info '] [' addr ']= ' Beijing '
#秦皇岛加2
info[1][' Lilei ' [' House '] [' qinhuangdao '] + = 2
#给lilei加一个性别
info[1][' lilei ' [' Sex ']= ' female '

#记录学生是否交作业
#学生姓名
#日期
#状态
#如果学生存在就增加一条日期状态, if not present, increase student's name and date status
The dictionary structure should be as follows:
stu = {
' Dawn ': {
' 2018-5-1 ': ' Not delivered ',
' 2018-5-2 ': ' Delivered '
},
' Wang Li ': {
' 2018-5-1 ': ' Not delivered ',
' 2018-5-2 ': ' Delivered '
}
}
The code is as follows:






Python Basic Dictionary Exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.