-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7-Set.py
56 lines (43 loc) · 1.2 KB
/
7-Set.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
# Set
# Set is another data structure
# Repreenr with ()
# Used to remove the duplicates---------------------------------------*
# Merge two sets with union method , Suppose you add more then 1 element is [] in this set --- set([])
# Set can have (tuples) in it but list and dictionaries are not allowed ,sets is unorder , Result {} it's appears its successfull running
# Strings can in set
Set_1 = set(['1', '2', '2', '4', '10']) # Mulit entry in Set use ['']
Set_2 = set(['5', '6', '10', '4', '1'])
# Adding in Set -------- .add()
# Set_1.add('2')
# Set_1.add('3')
# Union
# Set_union = Set_1.union(Set_2)
# print(Set_union)
# print(Set_1)
# print(Set_2)
# Intersection
# Set_intersection = Set_1.intersection(Set_2)
# print(Set_1)
# print(Set_2)
# print(Set_intersection)
# Set is supporting tuples only
# A = Set_1.add(100)
#
# print(A)
# print(Set_1)
# A = Set_1.add([200])
# print(Set_1) Set is not accepting List and Dict
# String adding in Set
# A = "Nishanth"
# B = "Mohan"
#
# Set_1.add(A)
# Set_2.add(B)
#
# print(Set_1)
# print(Set_2)
A = (" Hai Welcome " ," Good Morning","HAve a Nice Day")
#
Set_1.add(A)
print(Set_1)
# print(len(Set_1))