Skip to content

Commit d40823a

Browse files
committed
#18 - Python
1 parent 647fded commit d40823a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
conjunto = [1, 2, 3, 4, 5] # ya se que es una lista y no un conjunto
2+
print(conjunto)
3+
4+
conjunto.append("A")
5+
print(conjunto)
6+
7+
conjunto.insert(0, "b")
8+
print(conjunto)
9+
10+
conjunto.extend([-1, -2, -3])
11+
print(conjunto)
12+
13+
block = ["x", "y", "z"]
14+
for i, item in enumerate(block):
15+
conjunto.insert(i + 3, item)
16+
print(conjunto)
17+
18+
conjunto.pop(5)
19+
print(conjunto)
20+
21+
conjunto[7] = "C"
22+
print(conjunto)
23+
24+
print(-1 in conjunto)
25+
print(5 in conjunto)
26+
27+
conjunto.clear()
28+
29+
# ---- DIFUCULTAD EXTRA ----
30+
conjunto_a = {1, 2, 3, 4, 5}
31+
conjunto_b = {4, 5, 6, 7, 8}
32+
33+
print(conjunto_a.union(conjunto_b)) # unir ambos conjuntos
34+
print(conjunto_a.intersection(conjunto_b)) # elementos comunes
35+
print(conjunto_a.difference(conjunto_b)) # elementos en A que no estan en B
36+
print(conjunto_b.difference(conjunto_a)) # elementos en B que no estan en A
37+
print(conjunto_a.symmetric_difference(conjunto_b)) # insertesecion inversa

0 commit comments

Comments
 (0)