My Coding Quiz #4

in #hive-154226last year

My Coding Quiz #4 👨‍💻🛠️🧩

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


What's your choice?

Solution to the previous quiz: None, [-1, 4, 6]. In line 1 a list of numerical elements (a = [6, 4, -1]) is created and the same happens in line 2 (a = [1, 0]); nothing special so far.

Line 3 is where the heart of the matter lies. It contains: print(b.sort(), sorted(a)). The sort method is built-in to Python lists and what it does is to modify the list itself, in this case the one referenced with the identifier b. This function returns None. In contrast, the built-in sorted function returns a new list from an iterable. That is what differentiates the two functions. You probably knew it, because the previous post talked about it too. So None, [-1, 4, 6] is the expected 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 #4 👨‍💻🛠️🧩

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


¿Cuál es tu elección?

Solución al quiz anterior: None, [-1, 4, 6]. En la línea 1 se crea una lista de elementos numéricos (a = [6, 4, -1]) y lo mismo ocurre en la línea 2 (a = [1, 0]); nada especial hasta ahora.

La línea 3 es la que contiene la esencia del asunto. Esta contiene: print(b.sort(), sorted(a)). El método sort está integrado en las listas de Python y lo que hace es modificar la propia lista, en este caso aquella referenciada con el identificador b. Esa función retorna None. Por el contrario, la función integrada sorted retorna una nueva lista a partir de un iterable. Eso es lo que diferencia a ambas funciones. Probablemente lo sabías, pues además el anterior post hablaba de ello también. De tal modo que None, [-1, 4, 6] es la salida esperada.


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.

Sort:  

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

Congratulations @eniolw! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You have been a buzzy bee and published a post every day of the month.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Be ready for the July edition of the Hive Power Up Month!
Hive Power Up Day - July 1st 2023
Announcing the Travel Reimbursement Fund for HiveFest⁸