第六次作业(2018-03-21,周三)

6-1

inf = {"first_name":"Huan", "last_name":"Huang", "age":20, "city":"GuangZhou"}
print("first_name:"+inf["first_name"])
print("last_name:"+inf["last_name"])
print("age:",end = "")
print(inf["age"])

print("city:"+inf["city"])

6-3

vocabulary = {}
vocabulary["variable"] = "a quanlity that can assume any of a set of values"
vocabulary["string"] = "suquence of symbols or digits in computer programing"
vocabulary["annotation"] = "a comment or instruction(usually added)"
vocabulary["list"] = "a database containing an ordered array of items(names or topics)"
vocabulary["tuple"] = "an ordered list of elements"
print("variable:"+vocabulary["variable"])
print("string:"+vocabulary["string"])
print("annotation:"+vocabulary["annotation"])
print("list:"+vocabulary["list"])

print("tuple"+vocabulary["tuple"])

6-4

vocabulary = {}
vocabulary["variable"] = "a quanlity that can assume any of a set of values"
vocabulary["string"] = "suquence of symbols or digits in computer programing"
vocabulary["annotation"] = "a comment or instruction(usually added)"
vocabulary["list"] = "a database containing an ordered array of items(names or topics)"
vocabulary["tuple"] = "an ordered list of elements"
#print("variable:"+vocabulary["variable"])
#print("string:"+vocabulary["string"])
#print("annotation:"+vocabulary["annotation"])
#print("list:"+vocabulary["list"])
#print("tuple"+vocabulary["tuple"])
for voc,exp in vocabulary.items():

print(voc+":"+exp)

6-5

river = {"Long River":"China", "Yellow River":"China", "Nile":"Egypt"}
for riv,coun in river.items():
print("The "+riv+" runs through "+coun+".")
for riv in river.values():
print(riv)
for coun in river.keys():

print(coun)

6-6

favorite_language = {"jen":'python',"sarah":'c', "edwrad":'ruby', 'phil':'python'}
list = []
for name in favorite_language.keys():
if favorite_language[name]=='python':
list.append(name)
for name in list:
print("Thank you for your participation, "+name+".")
for name in favorite_language.keys():
if name not in list:

print("Would you like to participate in our investigation?"+name+".")

6-7

people = [{"first_name":"Huan", "last_name":"Huang", "age":20, "city":"GuangZhou"}, {"first_name":"Tao", "last_name":"Huang", "age":17, "city":"GanZhou"}, {"first_name":"JiaYi", "last_name":"Huang", "age":15, "city":"GanZhou"}]
for inf in people:
print("first_name:"+inf["first_name"])
print("last_name:"+inf["last_name"])
print("age:",end = "")
print(inf["age"])

print("city:"+inf["city"])

6-8

favorite_places = {"hhh":["GuangZhou","GanZhou", "BeiJing"],"hwt":["ShangHai", "ShenZhen", "HongKong"],"hjy":["NanChang", "ChengDu", "WuHan"]}
for name in favorite_places.keys():
print(name+"'s favorite_places: ",end = "")
for place in favorite_places[name]:
print(place+" ",end= "")

print("\n")


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值