1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # -*- coding: utf-8 -*- """Day 2. Subset and it's operation Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1u5i1vUSuv3TEthCZRd0hamaVX5hjC9hv """ #Equlity {0, 1} == {1, 0} zero = { 0 } zero2 = { 0 } zplus = { 0, 1} zminus = { 0,-1} # Is Subset Operation : <= # Is Stric Subset Operation : < zminus <= zplus zero <= zplus zplus < zminus zero < zero2 zero <= zero2 zplus.issuperset( zero ) ##################################### ############ UNION EXPRESSION ####### ##################################### A = { 1, 2 } B = { 2, 3 } ## UNION A | B A.union(B) ## InterSection A & B A.intersection(B) # difference A - B #### Symmetric difference => ( A - B ) | ( B - A ) A ^ B A.symmetric_difference(B) | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # -*- coding: utf-8 -*- """Day 2. Tuple And Cartesian Product.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1-FY5vhqZ5T1-rkRbwQ2HgyGtBBbYtipu """ from itertools import product faces = set ({ 'J', 'Q' , 'K'}) suit = set({ 'dia', 'spade'}) product(faces, suit) for i in product(faces, suit): print(i) | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # -*- coding: utf-8 -*- """Day 2.Cartesian Powers & Exponentials.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/19NVDNZd_exJ_fJf_LzefodVB-YAmlnWo """ import itertools #Cartesian Powers & Exponentials print(set(itertools.product({2, 5, 9}, repeat = 2))) | cs |
'딥러닝 모델 설계 > Python 공통' 카테고리의 다른 글
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 302: ordinal not in range(128) (0) | 2021.01.20 |
---|---|
lattice multivariate visualization With Seaborn (0) | 2019.07.09 |
google colaboratory, 원격 < - > 로컬 파일입출력, interective plot (0) | 2019.07.01 |
Pandas fundamental operations (0) | 2019.06.24 |
제일 효율적인 벡터화 연산 좋은 자료 (0) | 2019.06.19 |