-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6.sets.py
More file actions
88 lines (62 loc) · 1.79 KB
/
6.sets.py
File metadata and controls
88 lines (62 loc) · 1.79 KB
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
# मेरे Youtube चैनल को सबस्क्राइब करना ना भूलो ताकि आपको कोड का पूरा फ़्लो समझमे आए - https://www.youtube.com/channel/UCphs2JfmIClR62wbyf76HDg
# कोई भी सवाल है उसको मेरे यूट्यूब चैनल के कमेन्ट या डिस्कशन सेक्शन मे पूछ सकते हो - https://www.youtube.com/channel/UCphs2JfmIClR62wbyf76HDg/discussion
# और हाँ GitHub पर मुझे फॉलो करना ना भूलो ताकि सारे अपडेट एण्ड वर्क आपको मिलता रहे।
# set: index random
a = {2,3,4,5,6,7,865,3,2}
b = {4,3,2,5,6,7,6,5,5,4,38}
print('\ntype of a: ',type(a))
print('a: ',a)
print('b: ',b)
# add()
a.add(900)
# a.add()
print('a: ',a)
# update()
a.update([33,445,334,33223])
print('a update: ',a)
# len()
print('len: ',len(a))
# remove
a.remove(33223)
# a.remove(33223)
print('a: ',a)
# discard()
a.discard(445)
a.discard(445)
print('dicsard a: ',a)
# pop()
a.pop()
print('a pop: ',a)
# clear()
a.clear()
print('clear a: ',a)
# del
del a
# print('a del: ',a)
# join
print('b: ',b)
c = {3,4,5,6,8,6,4,3,4}
d = b.union(c)
print('union in d: ',d)
# update
# difference()
print('c: ',c)
print('\nb.difference(c): ',b.difference(c))
# intersection
print('b.intersection(c): ',b.intersection(c))
e = b.intersection(c)
# isdisjoint()
d = {33,444,555}
f = b.isdisjoint(d)
print('f: ',f)
# issubset()
z = b.issubset(c)
print('check issubset: ',z)
'''
Homework:
1. update() ko use karo aur chekc karo ki union and update kya similer kam karte hain?
2. difference_update() ?
3. discard()
4. intersection_update()
5. setdefault()
'''