• 第三周作业——列表,元组,字典


    1.
    strThat = '''Sarah Connor-that girl
    (That girl!)Ow~yeah! Um!Are you talk about me?
    (Um!Yes,I can trust.)
    Red carpet rolling, pockets are swollen
    Still got my friends, and with them I be flowing
    Rocking don't stopping and shopping
    Still coming on strong, I'll be flossy!
    This one's just for you
    I'm taking it to level,too.
    Tell me why you're talking trash
    They talk about that girl on the scene,
    Fusing that gucci on TV.(ah ha)
    That girl with the car
    20 inch rims on the jaguar.(ah ha)
    That girl on the show
    Thinking that bird just like a cock.(ah ha)
    That girl, that girl
    (That...taht...that...taht...that...)
    I take things step by step
    Until there's nothing left
    But the top and it don't stop
    When I sign off, I can hear the beat drop
    No matter what I do, I can't do right by you
    You can chat chat the chadder but it don't matter
    This is for you
    (Ha!Ha!Ha!...)
    They talk about that girl on the scene,
    Fusing that gucci on TV.(ah ha)
    That girl with the car
    20 inch rims on the jaguar.(ah ha)
    That girl on the show
    Thinking that bird just like a cock.(ah ha)
    That girl, that girl
    (That...taht...that...taht...that...)
    (That girl on the scene,fusing that gucci on TV.(ah ha)
    (That girl with the car,20 inch rims on the jaguar)(ah ha)
    (That girl on the scene,fusing that gucci on TV.(ah ha)
    (That...taht...that...taht...that...)
    I will be shining, you'll be crying
    You don't wanna front with me
    On Vina and on MTV
    I'm gonna still be me
    And I will be shining you'll be dying
    You don't wanna  front with me
    Toe to toe on MTV
    I'm gonna still be me
    They talk about that girl on the scene,
    Fusing that gucci on TV.(ah ha)
    That girl with the car
    20 inch rims on the jaguar.(ah ha)
    That girl on the show
    Thinking that bird just like a cock.(ah ha)
    That girl, that girl
    (That...taht...that...taht...that...)
    They talk about that girl on the scene,
    Fusing that gucci on TV.(ah ha)
    That girl with the car
    20 inch rims on the jaguar.(ah ha)
    That girl on the show
    Thinking that bird just like a cock.(ah ha)
    That girl, that girl
    (That...taht...that...taht...that...)
    They talk about that girl.
    -
    '''  
    strList = strThat.lower()
    print(strList)
    for word in strList:
        print(word)
    print(strList.count('girl'))
    strSet = set(strList)
    print(len(strSet),strSet)
    
    strDict = {}
    for word in strSet:
        strDict[word] = strList.count(word)
    
    print(len(strList),strList)
    
    2.
    s = {2,4,6,87,7,8,9,'Tom'}
    print(s)
    s.add('Nancy')
    print(s)
    s.remove(87)
    print(s)
    s1 = {1,2,4,7,5,0,'Tom',3}
    print(s1)
    set1 = s & s1
    print(set1)
    set2 = s| s1
    print(set2)
    set3 = s - s1
    print(set3)
    

     运行结果:

  • 相关阅读:
    SpringBoot项目启动与关闭脚本
    springboot mybatis启动初始化数据库
    springboot mybatis多数据库支持
    Tomcat配置https访问
    Oracle批量生成版本
    Oracle创建用户表空间
    OracleServiceXE服务没有了
    IDEA离线升级
    js过滤并校验XSS
    docker命令
  • 原文地址:https://www.cnblogs.com/MIS-67/p/9679992.html
Copyright © 2020-2023  润新知