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
{01== {10}
 
zero   = { 0   }
zero2  = { 0   }
zplus  = { 01}
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 #######
#####################################
 
 
= { 12 }
= { 23 }
 
## UNION
 
| B
 
A.union(B)
 
## InterSection
& B
 
A.intersection(B)
 
# difference
 
- 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({259}, repeat = 2)))
 
 
cs


+ Recent posts