# -*- coding: utf-8 -*-
# @Time : 2019/1/7 18:00
# @Author : Endless-cloud
# @Site :
# @File : day 13 课后作业.py
# @Software: PyCharm
'''
# 4.用map来处理字符串列表,把列表中所有人都变成sb,比方alex_sb
# name=[‘oldboy’,'alex','wusir']
'''
# name=['oldboy','alex','wusir']
# print(list(map(lambda i:i+'_sb',name)))
'''
# 5.用map来处理下述l,然后用list得到一个新的列表,列表中每个人的名字都是sb结尾
# l=[{'name':'alex'},{'name':'y'}]
'''
# l=[{'name':'alex'},{'name':'y'}]
# print(list(map(lambda dic: dic['name']+'sb',l )))
'''
# 6.用filter来处理,得到股票价格大于20的股票名字
# shares={
# 'IBM':36.6,
# 'Lenovo':23.2,
# 'oldboy':21.2,
# 'ocean':10.2,
# }
'''
# shares={
# 'IBM':36.6,
# 'Lenovo':23.2,
# 'oldboy':21.2,
# 'ocean':10.2,
# }
# print(list(filter(lambda x:shares[x]>20,shares.keys())))
'''
# 7.有下面字典,得到购买每只股票的总价格,并放在一个迭代器中。
# 结果:list一下[9110.0, 27161.0,......]
# portfolio = [
# {'name': 'IBM', 'shares': 100, 'price': 91.1},
# {'name': 'AAPL', 'shares': 50, 'price': 543.22},
# {'name': 'FB', 'shares': 200, 'price': 21.09},
# {'name': 'HPQ', 'shares': 35, 'price': 31.75},
# {'name': 'YHOO', 'shares': 45, 'price': 16.35},
# {'name': 'ACME', 'shares': 75, 'price': 115.65}]
'''
# portfolio = [
# {'name': 'IBM', 'shares': 100, 'price': 91.1},
# {'name': 'AAPL', 'shares': 50, 'price': 543.22},
# {'name': 'FB', 'shares': 200, 'price': 21.09},
# {'name': 'HPQ', 'shares': 35, 'price': 31.75},
# {'name': 'YHOO', 'shares': 45, 'price': 16.35},
# {'name': 'ACME', 'shares': 75, 'price': 115.65}]
# l =[1,2,3]
# print(list(map(lambda x:x+1,l)))
# print(list(map(lambda x:round(x['shares']*x['price'],1),portfolio)))
'''
# 8.还是上面的字典,用filter过滤出单价大于100的股票。
'''
# print(list(map(lambda x:x['name'],filter(lambda x:x['price']>100 ,portfolio))))
'''
# 9.有下列三种数据类型,
# l1 = [1,2,3,4,5,6]
# l2 = ['oldboy','alex','wusir','太白','日天']
# tu = ('**','***','****','*******')
# 写代码,最终得到的是(每个元祖第一个元素>2,第三个*至少是4个。)
# [(3, 'wusir', '****'), (4, '太白', '*******')]这样的数据。
'''
# l1 = [1,2,3,4,5,6]
# l2 = ['oldboy','alex','wusir','太白','日天']
# tu = ('**','***','****','*******')
# print(list(zip(l1,l2,tu)))
'''
# 10.有如下数据类型:
# l1 = [ {'sales_volumn': 0},
# {'sales_volumn': 108},
# {'sales_volumn': 337},
# {'sales_volumn': 475},
# {'sales_volumn': 396},
# {'sales_volumn': 172},
# {'sales_volumn': 9},
# {'sales_volumn': 58},
# {'sales_volumn': 272},
# {'sales_volumn': 456},
# {'sales_volumn': 440},
# {'sales_volumn': 239}]
# 将l1按照列表中的每个字典的values大小进行排序,形成一个新的列表。
'''
l1 = [ {'sales_volumn': 0},
{'sales_volumn': 108},
{'sales_volumn': 337},
{'sales_volumn': 475},
{'sales_volumn': 396},
{'sales_volumn': 172},
{'sales_volumn': 9},
{'sales_volumn': 58},
{'sales_volumn': 272},
{'sales_volumn': 456},
{'sales_volumn': 440},
{'sales_volumn': 239}]
# print(list(map(lambda x:{'sales_volumn':x},sorted(list(map(lambda i:i['sales_volumn'],l1))))))
print(sorted(l1,key=lambda i:i['sales_volumn']))
年与时驰,意与日去,遂成枯落,
多不接世,悲守穷庐,将复何及。