-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_sets.py
More file actions
50 lines (27 loc) · 894 Bytes
/
06_sets.py
File metadata and controls
50 lines (27 loc) · 894 Bytes
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
# Sets
my_set = set()
my_other_set = {}
print(type(my_set))
print(type(my_other_set))
my_other_set = {'Sergio', 'lattke', 23, 1.70}
print(type(my_other_set))
print(len(my_other_set))
my_other_set.add('Bacuchito') # a set is not an ordered structure and does not support repeated
print(my_other_set)
print('sergio' in my_other_set )
print('Sergio' in my_other_set )
my_other_set.remove(1.70)
print(my_other_set)
my_other_set.clear()
print(my_other_set)
del my_other_set
# print(my_other_set) NameError: name 'my_other_set' is not defined
my_set = {'python', 'javascript', 'markdown'}
print(type(my_set))
my_list = list(my_set)
print(my_list)
print(my_list[1])
my_other_set = {'Sergio', 'lattke', 23, 1.70}
my_new_set = (my_set.union(my_other_set).union(my_set).union({'java', 'nodejs'})) # sets cant duplicate
print(my_new_set)
print(my_new_set.difference(my_other_set))