파이썬 기초

Programming/Python

[Python-Basic] List Data Type - 1(Add)

kospi_top10 = ['삼성전자', 'SK하이닉스', '현대차', '한국전력', '아모레퍼시픽', '제일모직', '삼성전자우', '삼성생명', 'NAVER', '현대모비스'] # before adding print(kospi_top10) # add new item in list kospi_top10.append('SK텔레콤') print(kospi_top10) # change list name kospi_top11 = kospi_top10 print(kospi_top11) # insert new item after of specific item kospi_top11.insert(0, "JOHNMARK_AGC") print(kospi_top11) 실행결과 $ py list_add.py ['삼성전자',..

Programming/Python

[Python-Basic] Dictionary Data Type - 3

# Dictionary is save each data using by pair of key and value # Make dictionary type object using by '{' or '}' keyword current_price = {} # Check data type using 'type()' function. print(type(current_price)) # Add new item with key current_price['naver'] = 1 # Check result print(current_price) # Add another item with key current_price['DaumKAKAO'] = 2 # Check result print(current_price) # Lengt..

Programming/Python

[Python-Basic] Dictionary Data Type - 2

current_price = {'Daum KAKAO': 2, 'naver':1, 'wooaBrothers':3} print(current_price) # get all keys of dictionary object # keys() function return type is not list object print(current_price.keys()) # Should be change object type to list type list(current_price.keys()) list_keys = list(current_price) print(list_keys) # Extract values of each item in the dictionary list_value = list(current_price.v..

Programming/Python

[Python-Basic] Dictionary Data Type - 1

레포지토리를 뒤지다가 예전에 파이썬 공부를 하던 코드를 발견하였다. 당시 나는 빠르게 파이썬을 배우고 프로젝트에 적용했어야 됐어서 정말 얕은, 기본 수준으로만 빠르게 훑어봤었다. 이번 기회를 바탕으로 이를 좀 더 정리해서 포스팅을 연재하고자 한다. 가장 먼저 살펴볼 내용은 파이썬의 자료구조 중 하나인 딕셔너리 데이터 타입이다. 말 그대로 사전의 형태를 가진 자료형으로, 잘 생각해보면 우리는 사전을 볼 때 가장 먼저 낱말을 찾고, 낱말이 의미하는 바를 사전에서 확인한다. 이처럼 딕셔너리 데이터 타입은 키(낱말), 밸류(낱말의 뜻)으로 이루어져 있다. 다음은 딕셔너리 데이터 타입을 사용한 파이썬 코드의 예이다. current_price = {'Naver': 1, 'DaumKAKAO': 2} print(cur..

JohnMark
'파이썬 기초' 태그의 글 목록