Guest User

Untitled

a guest
Feb 22nd, 2018
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. # 1
  2.  
  3. 1. 튜플의 값들은 수정이 불가능하지만 리스트의 값들은 수정이 가능하다.
  4. 2. 튜플은 append 함수로 값들을 추가할 수 없지만 리스트는 append 함수로 값들을 추가할 수 있다:
  5. 3. 튜플은 읽기 전용으로 사용한다
  6.  
  7.  
  8. # 2
  9.  
  10. my_profile = {"이름":"송원준", "사는 곳":"용인 수지", "나이":33, "이메일":"balgarac1@naver.com"}
  11. print(my_profile)
  12.  
  13.  
  14. # 3
  15.  
  16. my_profile = {"이름":"송원준", "사는 곳":"용인 수지", "나이":33, "이메일":"balgarac1@naver.com"}
  17. brother_profile = {"이름":"송원재", "사는 곳":"용인 수지", "나이":32}
  18.  
  19. family = []
  20. my_profile_str = ""
  21. for k, v in my_profile.items():
  22. my_profile_str += k
  23. my_profile_str += ":"
  24. my_profile_str += str(v) + " "
  25.  
  26. family.append(my_profile_str)
  27.  
  28. brother_profile_str = ""
  29. for k, v in brother_profile.items():
  30. brother_profile_str += k
  31. brother_profile_str += ":"
  32. brother_profile_str += str(v) + " "
  33.  
  34. family.append(brother_profile_str)
  35.  
  36. print(family)
  37.  
  38.  
  39. # 4
  40.  
  41. my_profile = {"이름":"송원준", "사는 곳":"용인 수지", "나이":33, "이메일":"balgarac1@naver.com"}
  42. brother_profile = {"이름":"송원재", "사는 곳":"용인 수지", "나이":32}
  43.  
  44. family = []
  45. my_profile_str = ""
  46. for k, v in my_profile.items():
  47. my_profile_str += k
  48. my_profile_str += ":"
  49. my_profile_str += str(v) + " "
  50.  
  51. family.append(my_profile_str)
  52.  
  53. brother_profile_str = ""
  54. for k, v in brother_profile.items():
  55. brother_profile_str += k
  56. brother_profile_str += ":"
  57. brother_profile_str += str(v) + " "
  58.  
  59. family.append(brother_profile_str)
  60.  
  61. for k in range(0, len(family)):
  62. family[k] = family[k].strip().replace(" ", ",").replace(":", ",")
  63.  
  64. print(family)
  65.  
  66.  
  67. # 5
  68.  
  69. print(PEP)
  70.  
  71. alpha = {}
  72.  
  73. for letter in range(ord('a'), ord('z') + 1):
  74. if PEP.lower().count(chr(letter)):
  75. alpha[chr(letter)] = PEP.lower().count(chr(letter))
  76.  
  77. print(alpha)
  78.  
  79.  
  80. # 6
  81.  
  82. [1,2,3,4,5,6] => print([i for i in range(1,7)])
  83. [6,5,4,3,2,1] => print([i for i in reversed(range(1,7))])
  84. [[1,2,3],[1,2,3],[1,2,3]] => print([[i for i in range(1,4)] for i in range(1, 4)])
  85. [[1,2,3],[4,5,6],[7,8,9]] => print([[x for x in range(1, 4)],[x for x in range(4, 7)],[x for x in range(7, 10)]])
Add Comment
Please, Sign In to add comment