본문 바로가기

분류 전체보기333

[Python] list (sequence type) : summary list (Sequence Type) : Summary list는 ordered mutable collection으로, collection을 위한 python data type들 중 가장 많이 사용된다. C에서의 array와 같이 가장 기본적인 collection임. 단, heterogeneous item을 가질 수 있으며, 여러 methods를 가지는 객체라는 점이 array와 다름. Python에서 대표적인 sequence type인 것은 다음 세가지임. list : mutable sequence tuple : immutable sequence string : immutable text sequence sequence type은 indexing이 element의 위치(순서)에 의해 이루어지기 때문에 .. 2023. 7. 12.
[Python] set and frozenset set & frozenset set(집합) : 특정 conditions를 만족시키는 구별 가능한(distinct) object의 collection. set의 중요한 수학적 특징은 특정 object가 set에 속하는지 아닌지를 명확히 판별(특정 conditions에 의해)할 수 있음. set에 속한 object들은 element(원소)라고 부르고 이들 간은 구별 가능해야함 (동일한 object를 2개가 set에 속할 수 없음) 참고: 수학에서의 set https://dsaint31.tistory.com/679#Set%-A 이같은 특성 때문에, set에서 element간에는 특정한 order가 없고, 동일한 element(구별이 불가능한)가 2개 이상이 set에 속할 수 없다. Python에서 이 수학적 .. 2023. 7. 12.
[Python] Matplotlib Font설정 : 한글 사용하기 (colab). 현재 matplotlib가 사용하는 font의 family와 size 확인하기.matplotlib의 rcParams (runtime config parameters)에서 확인 가능함.import matplotlib as mplprint(f"font.family: {mpl.rcParams['font.family']}"), print(f"font.size : {mpl.rcParams['font.size']}") 2023.7.12 당시 colab의 경우, 다음과 같은 결과가 나옴.font.family: ['sans-serif']font.size : 10.0현재 matplotlib가 사용가능한 font들 확인하기.matplotlib의 font_manager를 통해 가능함.import matplotlib.fo.. 2023. 7. 12.
[Python] dictionary (Mapping type) : basic dictionary (dict)Python에서 dictionary는key-value pair를 item으로 가지는unorderedmutablecollection임.set과 함께 curly bracket (or brace)를 사용하는데, empty dictionary가 바로 {}로 표현됨(dictionary가 set보다 많이 이용되는 점이 반영된 듯...)dictionary는 key와 value가 하나의 item에 가지고 있고, 해당 key를 통한 indexing이 가능함.key는 set과 같이 unique 해야 한다.key들은 set과 같이 unordered 임.immutable object만이 key가 될 수 있음. mutable object는 hashable이지 않음... 2023. 7. 11.
[Python] Dictionary's methods Dictionary's methods비우기dic.clear()Dictionary instance (or object) dic을 전부 비움.모든 key-value 쌍들이 제거됨.<hr contenteditable="false" data-ke-type="horizontalRule" data-ke-s.. 2023. 7. 11.
[Python] 특정 점에서 직선에 수선의 발 구하기. 특정 pnt에서 두 점 segment_s(s), segment_e(e)로 정의된 line segment를 포함하는 line으로 수선의 발(foot of perpendicular line)를 내리는 경우는 다음과 같음. 위 그림에서 x가 바로 foot of perpendicular line임. 다음은 foot of perpendicular line (intersection)과 line-segment 중에서 pnt와 가장 가까운 점 (closet_pnt)을 반환하는 function을 구현한 예제임. def find_intersection_pnt( segment_s, segment_e, pnt): # Calculate the direction vector of the line segment defined by.. 2023. 7. 11.
반응형