Basic Sets Flashcards

1
Q

Crear un set a con miembros x y z

A
a = {x, y, z}
o
a = set([x, y, z])
a partir de una lista
o
a = set((x, y, z))
a partir de una tupla
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Crear un set a con rango de miembros n

A

a = set(range(n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Crear un set a de un string x

A

a = set(“x”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Crear un frozenset a con miembros x y z

A
a = frozenset([x, y, z])
a partir de una lista
o
a = frozenset((x, y, z))
a partir de una tupla
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Crear un frozenset a con rango de miembros n

A

a = frozenset(range(n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Crear un frozenset a de un string x

A

a = frozenset(“x”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Añadir miembro x a set a

A

a.add(x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Crear un set a vacío

A

a = set()

No sería correcto a = {}, esto es un diccionario

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Juntar miembros de sets a b

A

a. union(b)

b. union(a)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Obtener miembros en común de sets a b

A

a. intersection(b)

b. intersection(a)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Restar set b a set a

A

a.difference(b)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Restar set b a set a y guardar en set a

A

a.difference_update(b)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Restar simetricamente set b a set a

A

a.symmetric_difference(b)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Restar simetricamente set b a set a y guardar en set a

A

a.symmetric_difference_update(b)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Descartar miembro x de set a

A

a.discard(x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Eliminar miembro x de set a

A

a.remove(x)

Puede dar error si miembro x no existe en el set

17
Q

Devolver True si set a es subset de set b

A

a.issubset(b)

Subset es que los miebros del set a estan en el set b

18
Q

Devolver True si set a es superset de set b

A

a.issuperset(b)

Superset es que los miembros del set a contienen los miembros del set b