#튜플tuple () : 여러 개의 값을 하나로 묶는 자료형
#한 번 만들면 절대로 바꿀 수 없다!!
color = ('red', 'orange', 'yellow', 'green')
print(type(color))
# 1. 원소에 순서가 있다 - 인덱싱, 슬라이싱
print(color[2])
print(color[-2])
print(color[1:4])
page = [(1,2), (3,4), (5,6)]
print(page[1])
print(page[1][0])
print(color[2][1:3])
# 2. 어떤 원소를 찾을 수 있다 - in
print('blue' in color)
# 3. 원소의 길이를 확인할 수 있다 - len()
print(len(color))
# 4. 연결 연산을 할 수 있다 +
print(color + (2, 3, 4))
# 5. 반복 연산을 할 수 있다 *
print((3,) * 5) #튜플은 원소가 하나여도 쉼표 필수!!
# 6. 수정할 수 없다!!!
#color[0] = 'blue'
# color.append('pink')
# color.remove('red')
print('----숙제----')
animals = ('강아지', '고양이', '토끼', '햄스터', '앵무새')
# 1) '토끼'를 인덱싱으로 출력
print(animals[2])
#()소 {}중 []대
# 2) ('강아지', '토끼', '앵무새')을 슬라이싱으로 출력 - 칸 슬라이싱 이용
print(animals[::2])
# 3) 튜플에 '거북이'를 연결해서 출력
print(animals + ('거북이',))
# 4) 튜플에 '사자'가 포함되어 있는지 확인
print('사자' in animals)
# 5) 튜플의 길이를 출력
print(len(animals))
To embed this project on your website, copy the following code and paste it into your website's HTML: