This content was deleted by the author. You can see it from Blockchain History logs.

My Coding Quiz #17

My Coding Quiz #17 馃懆鈥嶐煉火煕狅笍馃З

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...




Quiz
By @eniolw


What's your choice?

Solution to the previous quiz: Error. We start by creating two variables a and b with the values 0 and 1 respectively, following the tuple unpacking notation. With these two variables, a set is created called c. Then we try to access the a and b members of c, but these are not actually defined members of the set class, so it will produce an error.

What's the point of the code then? Distinguish between Python syntax and Javascript syntax so as not to confuse them. Lines 2 and 3 make sense in Javascript, as they create an object with the variables a and b and are accessed by the dot operator. But this doesn't happen in Python: the expression {a, b} doesn't create a dictionary, it creates a set, as we said before. Even if they were dictionaries, their members are not accessed through the dot operator, but with the get method or with the square brackets.

Both @rafaelaquino and @splash-of-angs63 came up with the correct answer, even though an explanation could have been given as to why we got that output.


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 #17 馃懆鈥嶐煉火煕狅笍馃З

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...




Quiz
Por @eniolw


驴Cu谩l es tu elecci贸n?

Soluci贸n al quiz anterior: Error. Comenzamos por crear dos variables a y b con los valores 0 y 1 respectivamente, siguiendo la notaci贸n de desempaquetado de tuplas. Con esas dos variables se crea un conjunto (set) llamado c. Seguidamente, intentamos accededer a los miembros a y b de c, pero estos no son realmente miembros definidos de la clase set, por lo que se producir谩 un error.

驴Cu谩l es el punto del c贸digo entonces? Distinguir entre la sintaxis de Python y la sintaxis de Javascript para no confundirlas. Las l铆neas 2 y 3 tienen sentido en Javascript, pues crean un objeto con las variables a y b y se accede a ellas mediante el punto. Pero esto no ocurre Python: la expresi贸n {a, b} no crea un diccionario, sino que crea un set, como ya dijimos. A煤n si fuesen diccionarios, sus miembros no se acceden mediante el operador punto, sino con el m茅todo get o con los corchetes.

Tanto @rafaelaquino como @splash-of-angs63 dieron con la respuesta correcta, aunque se podr铆a haber dado una explicaci贸n de por qu茅 obtuvimos ese resultado.


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.