My Coding Quiz #16 馃懆鈥嶐煉火煕狅笍馃З
Welcome to the new installment of my series of Coding Quizzes, in which you will be able to test your knowledge and skills about programming and software development in a simple and fun way. If you want to learn more about it visit my blog here on Hive and the first post where I introduced it.
Without further ado, here's the riddle...

By 
What's your choice?
Solution to the previous quiz: [[2], [5, 6]]. First a list w is created with three nested lists and we know that lists are mutable objects.
Then a copy x of w is made using the built-in copy method. This method creates a shallow copy of an object, so the sublists of w are not actually copied, but referenced. As a consequence, the new list x still has access to the elements of w, since it did not store copies of them, but rather references, so those elements can be modified by manipulating the list x.
So, line 3 applies the pop method to x[0], which is the sublist [2, 1]. We know that pop by default removes the final element and returns it, so from [2, 1] the value 1 is removed and assigned to y, leaving that sublist at [2] and the list x at [[2], [3, 4], [5, 6]]. The content of w was also affected by being the same as x, so it also has [[2], [3, 4], [5, 6]].
Line 4 again applies the pop method to w, but this time specifies in the argument to remove the element at position y, meaning, 1. From the list w, which consists of [[2], [3, 4], [5, 6]], the sublist [3, 4] is removed and then assigned to z, although the code does nothing with that variable. The final composition of w is [[2], [5, 6]] and is what is printed at the end.
If you want to blog about computer science and programming content, I invite you to join Hive and participate in its communities, such as STEM-social, Develop Spanish, Programming & Dev, Hive Learners and others.
Mi Quiz de Programaci贸n #16 馃懆鈥嶐煉火煕狅笍馃З
Bienvenido a mi nueva serie de Quizzes de Programaci贸n, en la cual podr谩s poner a prueba tus conocimientos y habilidades sobre programaci贸n y desarrollo de software de una manera sencilla y divertida. Si quieres aprender m谩s sobre ella visita mi blog aqu铆 en Hive y el primer post donde la present茅.
Sin m谩s pre谩mbulos, he aqu铆 el acertijo...

Por 
驴Cu谩l es tu elecci贸n?
Soluci贸n al quiz anterior: [[2], [5, 6]]
. Primero se crea una lista w con tres listas anidadas y sabemos que las listas son objetos mutables.
Luego se hace una copia x de w usando el m茅todo incorporado copy. Este m茅todo crea una copia poco profunda de un objeto, por lo que las sublistas de w no son realmente copiadas, sino referenciadas. Como consecuencia, la nueva lista x aun tiene acceso a los elementos de w, pues no guard贸 copias de ellos, sino referencias, por lo que esos elementos pueden ser modificados manipulando la lista x.
Entonces, la l铆nea 3 aplica el m茅todo pop a x[0], que es la sublista [2, 1]. Sabemos que pop por defecto remueve el elemento final y lo retorna, por lo que de [2, 1] se remueve el valor 1 y se asigna a y, quedando esa sublista en [2] y la lista x en [[2], [3, 4], [5, 6]]. El contenido de w tambi茅n se vio afectado por ser el mismo de x, por lo que tambi茅n posee [[2], [3, 4], [5, 6]].
La l铆nea 4 aplica nuevamente el m茅todo pop a w, pero esta vez se especifica en el argumento que se remueva el elemento en la posici贸n y, es decir 1. De la lista w, que consiste en [[2], [3, 4], [5, 6]], se remueve la sublista [3, 4] y se asigna a z, aunque el c贸digo no hace nada con esa variable. La composici贸n final de w queda en [[2], [5, 6]] y es lo impreso al final.
Si quieres bloguear sobre contenido inform谩tico y de programaci贸n, te invito a unirte a Hive y participar en sus comunidades, tales como STEM-social, Develop Spanish, Programming & Dev, Hive Learners y otras.