1. 학습목표
2. 학습내용
# Tuple Advanced
# 튜플은 서로 다른 데이터 타입을 저장할 수 있는 컨테이너
# 튜플은 불변!
# Packing & Unpacking
# Un-Packing의 예
# print('EX5-1 -', divmod(100, 9))
# EX5-1 - (11, 1)
# Packing의 예
# print('EX5-1 -', divmod(*(100, 9)))
# print('EX5-2 -', divmod(100, 9))
# print('EX5-3 -', *(divmod(100,9)))
# EX5-3 - 11 1
x, y, *rest = range(10)
# print(x,y,rest)
# 0 1 [2, 3, 4, 5, 6, 7, 8, 9]
x, y, *rest = range(2)
# print(x,y,rest)
# 0 1 []
x, y, *rest = 1,2,3,4,5
# print(x,y,rest)
# 1 2 [3, 4, 5]
# mutable vs. immutable
l = (10, 15, 20)
m = [10, 15, 20]
# print(l, m, id(l), id(m))
# (10, 15, 20) [10, 15, 20] 4338117728 4337119176
# 새.로.운. 객체로 저장!!
l = l * 2
m = m * 2
# print(l, m, id(l), id(m))
# (10, 15, 20, 10, 15, 20) [10, 15, 20, 10, 15, 20] 4337903560 4337840904
# 자기 한테 수정! 리스트의 경우 조심!!!! 쉘로 카피?!
l *= 2
m *= 2
# print(l, m, id(l), id(m))
# (10, 15, 20, 10, 15, 20, 10, 15, 20, 10, 15, 20) [10, 15, 20, 10, 15, 20, 10, 15, 20, 10, 15, 20] 4319444568 4329583368
# l[0] = 100
"""
Traceback (most recent call last):
File "/Users/marie/PycharmProjects/untitled1/fc_lecture.py", line 43, in <module>
l[0] = 100
TypeError: 'tuple' object does not support item assignment
"""
m[0] = 100
# print(m)
# [100, 15, 20, 10, 15, 20, 10, 15, 20, 10, 15, 20]
3. 느낀 점