Basic Lists, Ranges, Tuples Flashcards

1
Q

Indicar rango de números n m

A

range(n, m)

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

Indicar rango de números n m con salto l

A

range(n, m, l)

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

Indicar rango de números 0 n

A

range(n)

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

Indicar rango de números 0 n con salto m

A

range(0, n, m)

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

Crear variable a rango de numeros 0 a n

A

a = range(n)

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

Crear variable a con rango desde un slice de otra variable b con rango

A

a = b[:]

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

Imprimir una tupla x y z

A

print((x, y, z))

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

Imprimir una lista x y z

A

print([x, y, z])

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

Crear variable a tupla de elementos x y z

A

a = (x, y, z)
o
a = x, y, z
menos recomendable

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

Crear variable a lista de strings de x0 a x2

A

a = [“x0”, “x1”, “x2”]
o
a = list(“x0”, “x1”, “x2”)

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

Crear variable a lista de numeros de n0 a n2

A

a = [n0, n1, n2]
o
a = list(n0, n1, n2)

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

Indicar lista de rango numérico n

A

list(range(n))

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

Modificar una variable a tupla x y z reemplazando y

A

a = (a[0], w, a[2])

donde w es un elemento nuevo

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

Modificar una variable a tupla x y z añadiendo un elemento w

A

a = (a[0], a[1], a[2], w)

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

Modificar una variable a lista x y z reemplazando y

A

a[1] = w

donde w es un elemento nuevo

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

Extraer (despaquetar) elementos x y z de una variable a lista o tupla

A

b, c, d = a

17
Q

Obtener índice del elemento x de una lista o tupla a

A

a.index(x)

18
Q

Crear variable string x, con elementos string y de una lista, separados por string z

A

x = “z”.join(y)

19
Q

Crear variable lista x, con cada palabra de un string y

A

x = y.split()

20
Q

Crear variable lista x, con cada segmento de un string y separado por el separador z no incluido

A

x = y.split(“z”)

21
Q

Añadir elemento x a una lista a

A

a.append(x)

22
Q

Devolver elemento x de una lista a, y eliminarlo

A

a.pop(x)

No x, por defecto ultimo elemento