create account

My Coding Quiz #52 by eniolw

View this thread on: hive.blogpeakd.comecency.com
· @eniolw ·
$17.68
My Coding Quiz #52
<div class="text-justify">

<center><h2>My Coding Quiz #52 👨‍💻🛠️🧩</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/DQmbFiucpukLELTeqza1DXyQLdPT45dbnVEKiUEjT8jmGUv/imagen.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-51">previous quiz</a>:</b> <b>([1, 2, 3, 4, 4],)</b>. We start by creating a tuple containing the list <code>[1, 2, 3, 4]</code>. As we can see, this tuple <code>a</code> has a comma at the end, and Python connoisseurs know that this is mandatory in order to denote a tuple of at least one item. Otherwise, the parenthesis would not create a tuple and would instead represent a grouping.</p>

<p>This explains why by doing <code>b = a[-1]</code>, we are accessing the last element of the tuple, which is the mentioned list and not an empty element. Surely you knew this, it's very basic.</p>

<p>What you might not know are all the roles of all the parameters of all the functions and methods that we use even on a daily basis. This may be the case of the instruction <code>b.insert(5, 4)</code>, which highlights the <code>insert</code> method. We know that it should insert something into list <code>b</code>, but how should it be read? Which parameter represents the content to be inserted and which parameter represents the position where it will be inserted? The answer is that the first argument is the position and the second argument is the content.</p>

<p>So, since <code>b</code> has <code>[1, 2, 3, 4]</code>, the instruction <code>b.insert(5, 4)</code> will insert a <code>4</code> at position <code>5</code>, so we get <b>[1, 2, 3, 4, 4, 4]</b>. Of course, what is printed at the end is <code>([1, 2, 3, 4, 4],)</code> because although the wrapper is a tuple and as such is immutable, its content is a list and this is mutable. We accessed it by referencing it with the variable <code>b</code> and then modified it with <code>insert</code>.</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 #52 👨‍💻🛠️🧩</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/DQmVR4hYeaV7S9x7jfNNGt2WmgjTx3xnzJrxhZUqd6Fqamc/imagen.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-51">quiz anterior</a>:</b> <b>([1, 2, 3, 4, 4],)</b>. Comenzamos creando una tupla que contiene la lista <code>[1, 2, 3, 4]</code>. Como podemos ver, esta tupla <code>a</code> tiene una coma al final, y los conocedores de Python saben que esto es obligatorio para denotar una tupla de al menos un elemento. De lo contrario, el paréntesis no crearía una tupla sino que representaría una agrupación.</p>

<p>Esto explica por qué al hacer <code>b = a[-1]</code>, estamos accediendo al último elemento de la tupla, que es la lista mencionada y no un elemento vacío. Seguro que lo sabías, es muy básico.</p>

<p>Lo que quizás no sepas son todas las funcionalidades de todos los parámetros de todas las funciones y métodos que utilizamos incluso a diario. Este puede ser el caso de la instrucción <code>b.insert(5, 4)</code>, que destaca el método <code>insert</code>. Sabemos que debería insertar algo en la lista <code>b</code>, pero ¿cómo debería leerse? ¿Qué parámetro representa el contenido a insertar y qué parámetro representa la posición donde se insertará? La respuesta es que el primer argumento es la posición y el segundo argumento es el contenido.</p>

<p>Entonces, dado que <code>b</code> tiene <code>[1, 2, 3, 4]</code>, la instrucción <code>b.insert(5, 4)</code> inserta un <code>4</code> en la posición <code>5</code>, por lo que obtenemos <b>[1, 2, 3, 4, 4, 4]</b>. Por supuesto, lo que se imprime al final es <code>([1, 2, 3, 4, 4],)</code> porque aunque el contenedor es una tupla y como tal es inmutable, su contenido es una lista y esto es mutable. Accedimos a él haciendo referencia a él con la variable <code>b</code> y luego lo modificamos con <code>insert</code>.</p>
</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>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 528 others
properties (23)
authoreniolw
permlinkmy-coding-quiz-52
categoryhive-197685
json_metadata"{"image":["https://images.ecency.com/DQmbFiucpukLELTeqza1DXyQLdPT45dbnVEKiUEjT8jmGUv/imagen.png","https://images.ecency.com/DQmVR4hYeaV7S9x7jfNNGt2WmgjTx3xnzJrxhZUqd6Fqamc/imagen.png"],"tags":["hive-197685","programming","coding","python","quiz","chess","neoxian","proofofbrain","creativecoin","waivio","spanish"],"description":"My Coding Quiz #52 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 fun way.","app":"ecency/3.1.0-vision","format":"markdown+html","image_ratios":["1.2887","1.2887"]}"
created2024-03-16 17:49:45
last_update2024-03-16 17:49:45
depth0
children3
last_payout2024-03-23 17:49:45
cashout_time1969-12-31 23:59:59
total_payout_value8.896 HBD
curator_payout_value8.788 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,546
author_reputation253,650,633,664,455
root_title"My Coding Quiz #52"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,100,130
net_rshares35,810,352,845,958
author_curate_reward""
vote details (592)
@daniel2001 ·
@tipu curate 8
properties (22)
authordaniel2001
permlinkre-eniolw-saipnx
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"peakd/2024.3.3"}
created2024-03-18 00:35:57
last_update2024-03-18 00:35:57
depth1
children1
last_payout2024-03-25 00:35:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length14
author_reputation381,604,085,995,528
root_title"My Coding Quiz #52"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,131,831
net_rshares0
@tipu ·
<a href="https://tipu.online/hive_curator?daniel2001" target="_blank">Upvoted  &#128076;</a> (Mana: 0/63) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
properties (22)
authortipu
permlinkre-re-eniolw-saipnx-20240318t003602z
categoryhive-197685
json_metadata"{"app": "beem/0.24.26"}"
created2024-03-18 00:36:03
last_update2024-03-18 00:36:03
depth2
children0
last_payout2024-03-25 00:36:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length217
author_reputation55,909,940,232,228
root_title"My Coding Quiz #52"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,131,834
net_rshares0
@stemsocial ·
re-eniolw-my-coding-quiz-52-20240317t174630761z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> 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.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-eniolw-my-coding-quiz-52-20240317t174630761z
categoryhive-197685
json_metadata{"app":"STEMsocial"}
created2024-03-17 17:46:30
last_update2024-03-17 17:46:30
depth1
children0
last_payout2024-03-24 17:46:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length565
author_reputation22,905,425,648,299
root_title"My Coding Quiz #52"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,123,528
net_rshares0