zoukankan      html  css  js  c++  java
  • day 14作业

    dict = {'name': '', 'sex': '', 'age': '', 'salary': ''}
    lists = []
    with open('test.txt', 'r+', encoding='utf8') as fr:
    for i in fr:
    liv = i.strip().split(' ')
    # print(liv)
    res = {k: v for k, v in zip(dict, liv)}
    # print(res)
    lists.append(res)
    # print(res.next())
    print(lists)

    薪资最高

    res = max(lists, key=lambda name: name['salary'])
    print(res)

    最年轻

    yong = min(lists, key=lambda age: age['age'])
    print(yong)

    大写名字第一个字母

    for i in range(len(lists)):

    lists[i]['name'] = lists[i]['name'].title()

    print(lists)

    res = map(lambda f: f['name'].title(), lists)
    lists1 = list(res)
    print(lists1)

    删除a开头的人的信息

    for i in range(len(lists)-1):

    if lists[i]['name'][0] == 'a':

    del lists[i]

    print(lists)

    res = filter(lambda f: not f['name'].startswith('a'), lists)

    lists2 = list(res)

    print(lists2)

    a = 0
    b = 1
    count = 0

    while count <5:

    print(a, b)

    a += b

    b += a

    count +=1

    菲波拉切数列

    def fb():

    global a

    global b

    global count

    count += 1

    print(a, b,end=' ')

    a += b

    b += a

    if count == 10:

    return

    return fb()

    fb()

  • 相关阅读:
    set
    网络流学习(最小费用最大流)
    网络流学习(最大流)
    模拟退火学习
    NOI Day1T1归程(Kruskal重构树+Dijkstra)
    线性基学习
    高斯消元学习
    manacher算法学习(求最长回文子串长度)
    AC自动机模板2
    AC自动机入门
  • 原文地址:https://www.cnblogs.com/LZF-190903/p/11588583.html
Copyright © 2011-2022 走看看