-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathset-operators.py
98 lines (61 loc) · 2.33 KB
/
set-operators.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import shared
def linq46():
factors_of300 = [2, 2, 3, 5, 5]
unique_factors = set(factors_of300)
print("Prime factors of 300:")
shared.printN(unique_factors)
def linq47():
products = shared.getProductList()
category_names = {p.Category for p in products}
print("Category names:")
shared.printS(category_names)
def linq48():
numbers_a = [0, 2, 4, 5, 6, 8, 9]
numbers_b = [1, 3, 5, 7, 8]
unique_numbers = set(numbers_a + numbers_b)
print("Unique numbers from both arrays:")
shared.printN(unique_numbers)
def linq49():
products = shared.getProductList()
customers = shared.getCustomerList()
product_first_chars = {p.ProductName[0] for p in products}
customer_first_chars = {c.CompanyName[0] for c in customers}
unique_first_chars = product_first_chars.union(customer_first_chars)
print("Unique first letters from Product names and Customer names:")
shared.printS(unique_first_chars)
def linq50():
numbers_a = [0, 2, 4, 5, 6, 8, 9]
numbers_b = [1, 3, 5, 7, 8]
common_numbers = set(numbers_a).intersection((set(numbers_b)))
print("Common numbers shared by both arrays:")
shared.printN(common_numbers)
def linq51():
products = shared.getProductList()
customers = shared.getCustomerList()
product_first_chars = {p.ProductName[0] for p in products}
customer_first_chars = {c.CompanyName[0] for c in customers}
unique_first_chars = product_first_chars.intersection(customer_first_chars)
print("Common first letters from Product names and Customer names:")
shared.printS(unique_first_chars)
def linq52():
numbers_a = [0, 2, 4, 5, 6, 8, 9]
numbers_b = [1, 3, 5, 7, 8]
a_only_numbers = set(numbers_a).difference((set(numbers_b)))
print("Numbers in first array but not second array:")
shared.printN(a_only_numbers)
def linq53():
products = shared.getProductList()
customers = shared.getCustomerList()
product_first_chars = {p.ProductName[0] for p in products}
customer_first_chars = {c.CompanyName[0] for c in customers}
unique_first_chars = product_first_chars.difference(customer_first_chars)
print("First letters from Product names, but not from Customer names:")
shared.printS(unique_first_chars)
linq46()
# linq47()
# linq48()
# linq49()
# linq50()
# linq51()
# linq52()
# linq53()