같은 종류의 데이터를 효율적으로 관리하기 위해 사용합니다!
같은 종류의 데이터를 순차적으로 저장
빠른 접근이 가능(인덱스 번호로 접근시)
데이터의 추가/삭제가 어려움
미리 최대 길이를 설정해야 함
# 1차원 배열: 리스트로 구현
arr_list = [1, 2, 3, 4, 5]
print(arr_list)
# 2차원 배열: 리스트로 구현
arr_list = [[1,2,3],[4,5,6],[7,8,9]]
print(arr_list)
# dataset 배열에서 전체 이름안에 'M'이 몇번 나왔는지 빈도수를 측정해보자
dataset = ['Braund, Mr. Owen Harris',
'Cumings, Mrs. John Bradley (Florence Briggs Thayer)',
'Heikkinen, Miss. Laina',
'Futrelle, Mrs. Jacques Heath (Lily May Peel)',
'Allen, Mr. William Henry',
'Moran, Mr. James',
'McCarthy, Mr. Timothy J',
'Palsson, Master. Gosta Leonard',
'Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg)',
'Nasser, Mrs. Nicholas (Adele Achem)',
'Sandstrom, Miss. Marguerite Rut',
'Bonnell, Miss. Elizabeth',
'Saundercock, Mr. William Henry',
'Andersson, Mr. Anders Johan',
'Vestrom, Miss. Hulda Amanda Adolfina',
'Hewlett, Mrs. (Mary D Kingcome) ',
'Rice, Master. Eugene',
'Williams, Mr. Charles Eugene',
'Vander Planke, Mrs. Julius (Emelia Maria Vandemoortele)',
'Masselmani, Mrs. Fatima',
'Fynney, Mr. Joseph J',
'Beesley, Mr. Lawrence',
'McGowan, Miss. Anna "Annie"',
'Sloper, Mr. William Thompson',
'Palsson, Miss. Torborg Danira',
'Asplund, Mrs. Carl Oscar (Selma Augusta Emilia Johansson)',
'Emir, Mr. Farred Chehab',
'Fortune, Mr. Charles Alexander',
'Dwyer, Miss. Ellen "Nellie"',
'Todoroff, Mr. Lalio']
count = 0;
for i in dataset:
m =i.count('M')
count+=m
print(count)
m_count = 0
for data in dataset:
for index in range(len(data)):
if data[index] == 'M':
m_count += 1
print(m_count)
멀티테스킹을 위한 프로세스 스케쥴링 방식을 구현(운영체제)
( 푸시메시지 = notification , 운영체제 프로그램...)
Enqueue: 큐에 데이터를 넣는 기능
Dequeue: 큐에 데이터를 꺼내는 기능
// 링크: https://visualgo.net/en/list
Queue(): 가장 일반적인 큐 자료구조 생성
LifoQueue(): ~=stack 나중에 입력된 데이터가 먼저 출력되는 구조
priorityQueue(): 데이터마다 우선순위를 넣어서 우선순위가 높은 순으로 데이터 출력
import queue
data_queue = queue.Queue() # 일반적인 큐
data_queue.put('apple') # Enqueue
print(data_queue) # <queue.Queue object at 0x7f9138c55f40>
print(data_queue.qsize()) #1
data_queue.put('banana')
print(data_queue.qsize()) #2
print(data_queue.get()) #apple
print(data_queue.qsize()) #1
print(data_queue.get()) #banana
print(data_queue.qsize()) #0