zoukankan      html  css  js  c++  java
  • 第三周作业——列表,元组,字典

    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)
    

     运行结果:

  • 相关阅读:
    Java程序员必知的8大排序(转载)
    Eclipse快捷键大全(转载)
    Java强引用、 软引用、 弱引用、虚引用(转)
    java数据类型二(转)
    为什么静态成员、静态方法中不能用this和super关键字(转)
    POJ 2002
    POJ 3126的教训
    POJ 3349
    POj 1105解题报告
    POJ 3278
  • 原文地址:https://www.cnblogs.com/MIS-67/p/9679992.html
Copyright © 2011-2022 走看看