Skip to content

Commit b78e6e7

Browse files
#18 - Python
1 parent b14c5c1 commit b78e6e7

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
### Python Data Structures ###
2+
3+
my_data = [1, 4, 5, 8, 10, 50, 100, 500]
4+
5+
my_data.append(800)
6+
print(my_data)
7+
8+
my_data.insert(0, 200)
9+
print(my_data)
10+
11+
my_data.extend([4, 8, 15])
12+
print(my_data)
13+
14+
my_data[4:5] = [12, 14, 16]
15+
print(my_data)
16+
17+
my_data.pop(-1)
18+
my_data.pop(5)
19+
print(my_data)
20+
21+
my_data[2] = 800
22+
print(my_data)
23+
24+
print(800 in my_data)
25+
26+
my_data.clear()
27+
print(my_data)
28+
29+
#! Optional Challenge
30+
list_one = [1, 5, 8, 10, 12, 15]
31+
list_two = [20, 11, 15, 45, 8, 50]
32+
33+
#? Union
34+
new_list = list_one + list_two
35+
new_list = [*list_one, *list_two]
36+
print(new_list)
37+
38+
#? Intersection
39+
intersection_list = [num for num in list_one if num in list_two]
40+
print(intersection_list)
41+
42+
#? Differece
43+
difference_list = [num for num in list_one if num not in list_two]
44+
print(difference_list)
45+
46+
#? Symmetric Difference
47+
symm_diff_list = list(set(list_one).symmetric_difference(set(list_two)))
48+
print(symm_diff_list)

0 commit comments

Comments
 (0)