My Coding Quiz #29

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@eniolw·
0.000 HBD
My Coding Quiz #29
<div class="text-justify">

<center><h2>My Coding Quiz #29 👨‍💻🛠️🧩</h2></center>

<p>Welcome to the new installment of my series of <b>Coding Quizzes</b>, 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 <a href="/@eniolw">my blog</a> here on Hive and the <a href="/@eniolw/my-coding-quiz-1">first post</a> where I introduced it.</p>

<h3>Without further ado, here's the riddle...</h3>

<br>
<center>
<img src="https://images.ecency.com/DQmXRhezdKYRRkU3GWbF1bFYSDeXbks5cTt2Cvf66WTZMRk/quiz_img_en.png" alt="Quiz">
<h6>By @eniolw</h6>
</center>

<br><center><h3>What's your choice?</h3></center>

<p><b>Solution to the <a href="/@eniolw/my-coding-quiz-28">previous quiz</a>:</b> Line 1 simply creates a <code>d</code> list of two numeric elements, while line 2 creates an inline <code>func</code> function that takes a parameter and applies the <code>pop</code> method to it., returning the removed value.</p>

<p>Line 3 introduces the function <code>all</code>, which evaluates a list that, as we will see, is modified at run time. We see that <code>func</code> is called a couple of times, providing the list <code>d</code> as an argument and this is modified, since <i>it is a pass by reference</i>. By the time the value of the third list element on line 3 is evaluated, <code>d</code> will be empty, so it will be considered <b>Falsy</b>. The results that <code>all</code> will evaluate will then be <b>-1</b>, <b>2</b> and <b>[]</b>.</p>


<p>The <code>all</code> function returns True if and only if all the elements in the given list are Truthy, but in our case that is impossible. Hence the value of <code>r</code> is <b>False</b> and is what is printed on the screen at the end.</p>

<hr>

<p>If you want to blog about computer science and programming content, I invite you to join <a href="/">Hive</a> and participate in its communities, such as <a href="/created/hive-196387">STEM-social</a>, <a href="/created/hive-154226">Develop Spanish</a>, <a href="/created/hive-169321">Programming & Dev</a> and others.</p>

<hr>

<center><h2>Mi Quiz de Programación #29 👨‍💻🛠️🧩</h2></center>

<p>Bienvenido a mi nueva serie de <b>Quizzes de Programación</b>, 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 <a href="/@eniolw">mi blog</a> aquí en Hive y el <a href="/@eniolw/my-coding-quiz-1">primer post</a> donde la presenté.</p>

<h3>Sin más preámbulos, he aquí el acertijo...</h3>

<br>
<center>
<img src="https://images.ecency.com/DQmNeVfWhGJKrJmmeFogMtva93GgtAVyRpiy4sDmyKm8CAr/quiz_img_es.png" alt="Quiz">
<h6>Por @eniolw</h6>
</center>

<br><center><h3>¿Cuál es tu elección?</h3></center>

<p><b>Solución al <a href="/@eniolw/my-coding-quiz-28">quiz anterior</a>:</b> <b>False</b>. La línea 1 simplemente crea una lista <code>d</code> de dos elementos numéricos, mientras que la línea 2 crea una función inline <code>func</code> que toma un parámetro y le aplica el método <code>pop</code>, devolviendo el valor retirado.</p>

<p>La línea 3 introduce la función <code>all</code>, la cual evalúa una lista que, como veremos, es modificada en tiempo de ejecución. Vemos que se llama a <code>func</code> un par de veces, proveyendo la lista <code>d</code> como argumento y esta es modificada, pues <i>es un paso por referencia</i>. Para cuando se evalúe el valor del tercer elemento de la lista de la linea 3, <code>d</code> estará vacía, por lo que se considerará como <b>Falsy</b> (falso). Los resultados que evaluará <code>all</code> serán entonces <b>-1</b>, <b>2</b> y <b>[]</b>.</p>


<p>La función <code>all</code> retorna True si y solo si todos los elementos de la lista dada son Truthy (verdaderos), pero en nuestro caso eso es imposible. De allí que el valor de <code>r</code> es <b>False</b> y es lo impreso en pantalla al final.</p>

<hr>

<p>Si quieres bloguear sobre contenido informático y de programación, te invito a unirte a <a href="/">Hive</a> y participar en sus comunidades, tales como <a href="/created/hive-196387">STEM-social</a>, <a href="/created/hive-154226">Develop Spanish</a>, <a href="/created/hive-169321">Programming & Dev</a> y otras.</p>

</div>
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,