create account

My Coding Quiz #54 by eniolw

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

<center><h2>My Coding Quiz #54 👨‍💻🛠️🧩</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/DQmcs7RurPUE7cWWCxGjnmWmScYKixnZ8yw2b2h2zRysLwh/image.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-53">previous quiz</a>:</b> <b>NameError</b>. Line 1 creates a <i>zip object</i>, which is useful for traversing two iterables in parallel. In this case it would be the string <code>"abc"</code> and the <code>range(1,4)</code> which, if resolved as a list, would consist of <b>[1, 2, 3]</b>, so both iterables are the same size.</p>

<p>Line 2 creates a dictionary <code>d</code> using the compression notation. We see that it would consist of key/value pairs formed by each parallel element traversed with the <code>zip</code> object, so if we were to print <code>d</code>, it would consist of <b>{'a': 1, 'b': 2, 'c': 3}</b>.</p>

<p>Line 3 should show one result, whichever is truthy of the three values joined with the <code>or</code> operator. Let's look at each one:</p>

<p>👉 <code>list(c)</code> will, in fact, produce the empty list <b>[]</b>, since <code>zip</code> is like a <i>generator</i>. This means that <i>once it is traversed, it is consumed</i>. We see that it was traversed on line 2, so it is already consumed at this point and produces nothing. An empty list is falsy.</p>

<p>👉 <code>d.get(1)</code> returns <b>None</b> since there is no key named <code>1</code> in the <code>d</code> dictionary. The None value is obviously falsy.</p>

<p>👉 <code>a</code>, on the other hand, will trigger the <b>NameError</b>, since it is a <i>local variable</i> inside the compressor block. <i>It does not exist outside it</i>. This explains the result obtained, which is not really an output, but an execution error.</p>

<p>What do you say, were you right with your choice?</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 #54 👨‍💻🛠️🧩</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/DQmWxSpoN4svYHPXTVZCqFRT1XUqa2AeqVVTKwNR5DewxVr/image.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-53">quiz anterior</a>:</b> <b>NameError</b>. La línea 1 crea un <i>objeto zip</i>, que es útil para atravesar dos iterables en paralelo. En este caso sería la cadena <code>"abc"</code> y el <code>range(1,4)</code> que, si se resuelve como una lista, consistiría en <b>[1, 2, 3]</b>, por lo que ambos iterables tienen el mismo tamaño.</p>

<p>La línea 2 crea un diccionario <code>d</code> usando la notación de compresión. Vemos que consistiría en pares clave/valor formados por cada elemento paralelo atravesado con el objeto <code>zip</code>, por lo que si imprimiésemos <code>d</code>, consistiría en <b >{'a': 1, 'b': 2, 'c': 3}</b>.</p>

<p>La línea 3 debería mostrar un resultado, el que sea verdadero (truthy) de los tres valores unidos con el operador <code>or</code>. Veamos cada uno:</p>

<p>👉 <code>list(c)</code> producirá, de hecho, la lista vacía <b>[]</b>, ya que <code>zip</code> es como un <i>generador</i>. Esto significa que <i>una vez que se atraviesa, se consume</i>. Vemos que fue recorrido por la línea 2, por lo que ya está consumido en este punto y no produce nada. Una lista vacía es falsa (falsy).</p>

<p>👉 <code>d.get(1)</code> devuelve <b>None</b> ya que no hay ninguna clave denominada <code>1</code> en el diccionario <code>d</code>. El valor None es obviamente falso (falsy).</p>

<p>👉 <code>a</code>, por otro lado, desencadenará el <b>NameError</b>, ya que es una <i>variable local</i> dentro del bloque compresor. <i>No existe fuera de él</i>. Esto explica el resultado obtenido, que en realidad no es una salida, sino un error de ejecución.</p>

<p>¿Qué dices, acertaste con tu elección?</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 575 others
properties (23)
authoreniolw
permlinkmy-coding-quiz-54
categoryhive-197685
json_metadata"{"image":["https://images.ecency.com/DQmcs7RurPUE7cWWCxGjnmWmScYKixnZ8yw2b2h2zRysLwh/image.png","https://images.ecency.com/DQmWxSpoN4svYHPXTVZCqFRT1XUqa2AeqVVTKwNR5DewxVr/image.png"],"tags":["hive-197685","programming","coding","python","quiz","chess","neoxian","proofofbrain","creativecoin","waivio","spanish"],"description":"My Coding Quiz #54 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.1-vision","format":"markdown+html","image_ratios":["1.2887","1.2887"]}"
created2024-03-23 21:26:51
last_update2024-03-23 21:26:51
depth0
children9
last_payout2024-03-30 21:26:51
cashout_time1969-12-31 23:59:59
total_payout_value10.176 HBD
curator_payout_value10.039 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,407
author_reputation253,650,633,664,455
root_title"My Coding Quiz #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,280,220
net_rshares36,312,855,171,772
author_curate_reward""
vote details (639)
@indiaunited ·
Indiaunited Curation 1711298315769
This post has been manually curated by @bhattg from Indiaunited community. Join us on our [Discord Server](https://discord.gg/bGmS2tE). 

Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens. HP delegators and IUC token holders also get upto 20% additional vote weight. 

Here are some handy links for delegations: [100HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=173278.5722055109%20VESTS), [250HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=433196.43051377725%20VESTS), [500HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=866392.8610275545%20VESTS), [1000HP](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=indiaunited&vesting_shares=1732785.722055109%20VESTS). 

[![image.png](https://files.peakd.com/file/peakd-hive/bala41288/46eaz12N-image.png)](https://discord.gg/bGmS2tE) 

<sub>**100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited.**</sub>
👍  
properties (23)
authorindiaunited
permlinkindiaunited-1711298315769
categoryhive-197685
json_metadata{"app":"hiveblog/0.1","format":"markdown","tags":["hive-197685","programming","coding","python","quiz","chess","neoxian","proofofbrain","creativecoin","waivio","spanish"]}
created2024-03-24 16:38:36
last_update2024-03-24 16:38:36
depth1
children1
last_payout2024-03-31 16:38:36
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_length1,327
author_reputation95,462,840,533,451
root_title"My Coding Quiz #54"
beneficiaries
0.
accountbhattg
weight10,000
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,297,471
net_rshares22,121,414,276
author_curate_reward""
vote details (1)
@eniolw ·
Thank you!
properties (22)
authoreniolw
permlinkre-indiaunited-savfwy
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"peakd/2024.3.5"}
created2024-03-24 21:34:12
last_update2024-03-24 21:34:12
depth2
children0
last_payout2024-03-31 21:34:12
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_length10
author_reputation253,650,633,664,455
root_title"My Coding Quiz #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,302,988
net_rshares0
@mireyaromero ·
@tipu curate 8
properties (22)
authormireyaromero
permlinkre-eniolw-savywb
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"peakd/2024.3.5"}
created2024-03-25 04:24:06
last_update2024-03-25 04:24:06
depth1
children2
last_payout2024-04-01 04:24:06
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_reputation23,179,311,363,500
root_title"My Coding Quiz #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,309,870
net_rshares0
@eniolw ·
Gracias!
👍  
properties (23)
authoreniolw
permlinkre-mireyaromero-2024325t152028657z
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"ecency/3.1.1-vision","format":"markdown+html"}
created2024-03-25 19:20:30
last_update2024-03-25 19:20:30
depth2
children0
last_payout2024-04-01 19:20: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_length8
author_reputation253,650,633,664,455
root_title"My Coding Quiz #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,326,578
net_rshares2,823,152,121
author_curate_reward""
vote details (1)
@tipu ·
<a href="https://tipu.online/hive_curator?mireyaromero" target="_blank">Upvoted  &#128076;</a> (Mana: 0/71) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
properties (22)
authortipu
permlinkre-re-eniolw-savywb-20240325t042413z
categoryhive-197685
json_metadata"{"app": "beem/0.24.26"}"
created2024-03-25 04:24:12
last_update2024-03-25 04:24:12
depth2
children0
last_payout2024-04-01 04:24:12
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_length219
author_reputation55,909,815,117,786
root_title"My Coding Quiz #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,309,872
net_rshares0
@stemsocial ·
re-eniolw-my-coding-quiz-54-20240324t211231142z
<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-54-20240324t211231142z
categoryhive-197685
json_metadata{"app":"STEMsocial"}
created2024-03-24 21:12:30
last_update2024-03-24 21:12:30
depth1
children0
last_payout2024-03-31 21:12: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 #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,302,578
net_rshares0
@yinjuolu ·
Wow. This is nicee!
Coding quiz. Do you Put up questions on R language?
properties (22)
authoryinjuolu
permlinkre-eniolw-sawbrl
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"peakd/2024.3.5"}
created2024-03-25 09:02:09
last_update2024-03-25 09:02:09
depth1
children2
last_payout2024-04-01 09:02:09
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_length71
author_reputation10,233,472,597,583
root_title"My Coding Quiz #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,313,588
net_rshares0
@eniolw ·
Thanks, do you have the answer to the quiz btw?
Maybe I also do quizzes with R. I'll take it as a suggestion!
properties (22)
authoreniolw
permlinkre-yinjuolu-2024325t15201640z
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"ecency/3.1.1-vision","format":"markdown+html"}
created2024-03-25 19:20:15
last_update2024-03-25 19:20:15
depth2
children1
last_payout2024-04-01 19:20:15
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_length109
author_reputation253,650,633,664,455
root_title"My Coding Quiz #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,326,575
net_rshares0
@yinjuolu ·
No I don't, cause I am not familiar with python
properties (22)
authoryinjuolu
permlinkre-eniolw-sb1s1w
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"peakd/2024.3.6"}
created2024-03-28 07:41:57
last_update2024-03-28 07:41:57
depth3
children0
last_payout2024-04-04 07:41: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_length47
author_reputation10,233,472,597,583
root_title"My Coding Quiz #54"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id132,399,641
net_rshares0