-
Python Chapter09방뚝딱 학습노트 2023. 10. 29. 19:30
교재 : 멘토씨리즈 파이썬
이중리스트
list의 원소 타입은 어떠한 자료형도 가능합니다.
list가 list의 원소가 될 수 있습니다.
이러한 list를 이중, 삼중…n중 리스트라고 표현합니다.
이중리스트는 2차원 문제를 해결할 때 주로 사용합니다.
이중 리스트는 두개의 인덱싱을 활용해 하나의 개별 원소에 접근합니다.
ex)
-리스트명 [][] : 개별 원소에 접근
-리스트명 [] : 1차원 리스트에 접근
실습)
예제1)
튜플
순서가 있다, 중복을 허용한다.
<튜플의 기본 구조>
animals=(’dog’,’cat’,’bird’,’fish’,’tiger’)
튜플은 ()가 없어도 튜플이고 튜플의 본질은 ,에 있습니다.
원소가 하나인 튜플을 만드려면 원소 뒤에 ,를 붙히면 됩니다.
animal2 = ‘dog’,
예제)
튜플연산
-+ : tuple 사이에 연산을 하면 두 개의 tuple을 합한 tuple이 나옵니다.
-*: tuple * 정수를 연산하여 해당 tuple이 정수 배 만큼 추가된 tuple이 나옵니다.
-in : tuple에 데이터가 존재하는지 bool타입으로 반환
'방뚝딱 학습노트' 카테고리의 다른 글
취업성공의 키포인트 면접 스피치 (2) 2023.11.01 PM 직무는 어떤 역할을 할까요? (0) 2023.11.01 Python Chapter08 (0) 2023.10.29 Python Chapter07 (0) 2023.10.18 Python Chapter06 (2) 2023.10.17