create account

My Coding Quiz #57 by eniolw

View this thread on: hive.blogpeakd.comecency.com
· @eniolw · (edited)
$15.85
My Coding Quiz #57
<div class="text-justify">

<center><h2>My Coding Quiz #57 馃懆鈥嶐煉火煕狅笍馃З</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/DQmbSrArXNwhhMDKvmDWcXjBrLEKyVJyFzQRWZUNjJuCyaQ/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-56">previous quiz</a></b>: <b>&#60;class 'set'&#62; False</b>. One more time we've used chess motifs to illustrate the concept of this code. This is how we created the set <code>moves</code>, which contains characters that represent moves in a chess game: <code>moves = {'e4', 'c5', 'd4', 'e4', 'cxd4'}</code>.</p>

<p>As we know, sets have unique elements, so the repeated element that was hardcoded (<code>'e4'</code>) is actually eliminated during the compilation and execution of the program. So, the set <code>moves</code> would actually consist of <b>{'c5', 'd4', 'e4', 'cxd4'}</b>.</p>

<p>Next, we create a list <code>numbers</code> with a sequence of natural numbers that correspond to the elements of the set <code>moves</code> one by one. This is useful to be able to enumerate the moves. In chess, the movements of a game are numbered in pairs (one white move and one black move represent a single pair), but at the programming level, each move corresponds to a single number. In case you need to see it, the content of <code>numbers</code> is <b>[0, 1, 2, 3]</b>.</p>

<p>Then we have the instruction <code>jug = [j1, j2, j3, j4] = moves</code>, which is curious and potentially confusing. There we make a chained assignment or mapping. Reading from left to right, we have <code>[j1, j2, j3, j4] = moves</code> and this is an unpacking: we are creating four variables and assigning to them items from <code>moves</code> in the order in which they appear; We are not creating a list.</p>

<p>That explains what occurs in the following part: <code>jug = [j1, j2, j3, j4]</code>. Here <code>jug</code> does not refer to any list, but directly to <code>moves</code>.</p>

<p>Finally we use <code>print</code> to show the output: <code>print(type(jug), {numbers[0]} < {numbers[1]})</code>. The first part produces the type of <code>jug</code>, which is a <b>set</b>.</p>

<p>The following part in the print deserves its own discussion: We are doing one of the multiple set operations. In this case, the <code>&#60;</code> operator serves to check whether a set is a proper subset of another. Here <code>{numbers[0]} < {numbers[1]}</code> consists of <code>{0} < {1}</code>. Even though the value of the element of the first set is smaller than that of the second, this is not how this operation works. The truth value here is <b>False</b> because <code>{0}</code> is not a subset of <code>{1}</code>.</p>

<p>That explains why the final output is <b>&#60;class 'set'&#62; False</b>. As you can see, even though it looks like a simple script, it contains several interesting concepts and details that even take time to understand and explain.</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 #57 馃懆鈥嶐煉火煕狅笍馃З</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/DQmVPD5tnu2VkvjHKPedthucuf3hpU3NBUtMhrPr1hS9QS3/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-56">quiz anterior</a></b>: <b>&#60;class 'set'&#62; False</b>. Nuevamente utilizamos motivos de ajedrez para ilustrar el concepto de este c贸digo. As铆 es como creamos el conjunto <code>moves</code>, que contiene caracteres que representan movimientos en un juego de ajedrez: <code>moves = {'e4', 'c5', 'd4', 'e4', ' cxd4'}</code>.</p>

<p>Como sabemos, los conjuntos tienen elementos 煤nicos, por lo que el elemento repetido que fue codificado (<code>'e4'</code>) en realidad se elimina durante la compilaci贸n y ejecuci贸n del programa. Entonces, el conjunto <code>moves</code> en realidad consistir铆a en <b>{'c5', 'd4', 'e4', 'cxd4'}</b>.</p>

<p>A continuaci贸n, creamos una lista <code>numbers</code> con una secuencia de n煤meros naturales que corresponden a los elementos del conjunto <code>moves</code> uno por uno. Esto es 煤til para poder enumerar los movimientos. En el ajedrez, los movimientos de una partida se numeran por parejas (una jugada de las blancas y otra de las negras representan un 煤nico par), pero a nivel de programaci贸n, cada jugada corresponde a un 煤nico n煤mero. En caso de que necesites verlo, el contenido de <code>n煤meros</code> es <b>[0, 1, 2, 3]</b>.</p>

<p>Luego tenemos la instrucci贸n <code>jug = [j1, j2, j3, j4] = moves</code>, que es curiosa y potencialmente confusa. All铆 realizamos una asignaci贸n o mapeo encadenado. Leyendo de izquierda a derecha, tenemos <code>[j1, j2, j3, j4] = moves</code> y esto es un desempaquetado: estamos creando cuatro variables y asign谩ndoles elementos de <code>moves</code> en el orden en que aparecen; no estamos creando una lista.</p>

<p>Eso explica lo que ocurre en la siguiente parte: <code>jug = [j1, j2, j3, j4]</code>. Aqu铆 <code>jug</code> no se refiere a ninguna lista, sino directamente a <code>movimientos</code>.</p>

<p>Finalmente usamos <code>print</code> para mostrar el resultado: <code>print(type(jug), {numbers[0]} < {numbers[1]})</code>. La primera parte produce el tipo de <code>jug</code>, que es un <b>set</b>.</p>

<p>La siguiente parte de la impresi贸n merece su propia discusi贸n: Estamos realizando una de las m煤ltiples operaciones de conjunto. En este caso, el operador <code>&#60;</code> sirve para comprobar si un conjunto es un subconjunto propio de otro. Aqu铆 <code>{numbers[0]} < {numbers[1]}</code> consta de <code>{0} < {1}</code>. Aunque el valor del elemento del primer conjunto es menor que el del segundo, esta operaci贸n no funciona as铆. El valor de verdad aqu铆 es <b>False</b> porque <code>{0}</code> no es un subconjunto de <code>{1}</code>.</p>

<p>Eso explica por qu茅 el resultado final es <b>&#60;class 'set'&#62; False</b>. Como puedes ver, aunque parece un script sencillo, contiene varios conceptos y detalles interesantes que incluso llevan tiempo comprender y explicar.</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 573 others
properties (23)
authoreniolw
permlinkmy-coding-quiz-57
categoryhive-197685
json_metadata"{"app":"ecency/3.1.1-vision","description":"My Coding Quiz #57 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.","format":"markdown+html","image":["https://images.ecency.com/DQmbSrArXNwhhMDKvmDWcXjBrLEKyVJyFzQRWZUNjJuCyaQ/imagen.png","https://images.ecency.com/DQmVPD5tnu2VkvjHKPedthucuf3hpU3NBUtMhrPr1hS9QS3/imagen.png"],"image_ratios":["0.9960","0.9960"],"tags":["hive-197685","programming","coding","python","chess","quiz","neoxian","proofofbrain","creativecoin","waivio","spanish"]}"
created2024-04-26 18:31:06
last_update2024-04-26 18:31:57
depth0
children9
last_payout2024-05-03 18:31:06
cashout_time1969-12-31 23:59:59
total_payout_value7.974 HBD
curator_payout_value7.876 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,632
author_reputation253,543,214,078,146
root_title"My Coding Quiz #57"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id133,146,130
net_rshares39,007,230,125,274
author_curate_reward""
vote details (637)
@anli · (edited)
Hey! What an awesome find today! You're doing dev quizzes. I definitely need to come back here. I'm just in my feed here today finding yours.

On the quiz above I have no clou yet and look forward to your solution in #58 hopefully. Would love to have me mentioned for not missing out. Your lesson reminds me of going  into regular expressions more, yet having little reason in a usual day in and day out as not being a dev yet.

Make this a great day!

!invest_vote
properties (22)
authoranli
permlinkre-eniolw-2024427t123028663z
categoryhive-197685
json_metadata{"type":"post","tags":["hive-197685","programming","coding","python","chess","quiz","neoxian","proofofbrain","creativecoin","waivio","spanish"],"app":"ecency/3.0.46-mobile","format":"markdown+html"}
created2024-04-27 10:30:30
last_update2024-04-27 10:31:21
depth1
children4
last_payout2024-05-04 10:30: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_length465
author_reputation22,251,606,504,045
root_title"My Coding Quiz #57"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id133,163,344
net_rshares0
@eniolw ·
Hey! Thank you for stopping by! I hope you like my coding series. Are you learning coding? If you follow me, I think you should get updates about my posts in your feed.
馃憤  
properties (23)
authoreniolw
permlinkre-anli-2024427t123339955z
categoryhive-197685
json_metadata{"tags":["hive-197685","programming","coding","python","chess","quiz","neoxian","proofofbrain","creativecoin","waivio","spanish"],"app":"ecency/3.1.1-vision","format":"markdown+html"}
created2024-04-27 16:33:39
last_update2024-04-27 16:33:39
depth2
children3
last_payout2024-05-04 16:33:39
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_length168
author_reputation253,543,214,078,146
root_title"My Coding Quiz #57"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id133,168,756
net_rshares6,656,218,619
author_curate_reward""
vote details (1)
@anli ·
No, I'm not learning to code. I've tried to go into it, though never had the patience to dive very deep. I'm more of an admin then a coder.

My feed is what led me here, yet that's not very reliable as I don't often can afford [days like today](https://ecency.com/hive-106444/@qwerrie/re-anli-scm1et). !LOLZ So I miss a lot that is in my feed.

Yet I now have added your account to my F.R.I.D.A.Y and look forward to more of your quizzes! 馃榾馃憤

!invest_vote
properties (22)
authoranli
permlinkre-eniolw-2024427t19553963z
categoryhive-197685
json_metadata{"tags":["hive-197685","programming","coding","python","chess","quiz","neoxian","proofofbrain","creativecoin","waivio","spanish"],"app":"ecency/3.1.1-vision","format":"markdown+html"}
created2024-04-27 17:05:54
last_update2024-04-27 17:05:54
depth3
children2
last_payout2024-05-04 17:05:54
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_length455
author_reputation22,251,606,504,045
root_title"My Coding Quiz #57"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id133,169,263
net_rshares0
@miriannalis ·
@tipu curate 8
properties (22)
authormiriannalis
permlinkre-eniolw-scmfua
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"peakd/2024.4.3"}
created2024-04-27 21:55:15
last_update2024-04-27 21:55:15
depth1
children2
last_payout2024-05-04 21:55: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_length14
author_reputation304,689,227,513,599
root_title"My Coding Quiz #57"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id133,176,600
net_rshares0
@eniolw ·
$0.08
Gracias!
馃憤  
properties (23)
authoreniolw
permlinkre-miriannalis-2024429t163519520z
categoryhive-197685
json_metadata{"tags":["hive-197685"],"app":"ecency/3.1.1-vision","format":"markdown+html"}
created2024-04-29 20:35:21
last_update2024-04-29 20:35:21
depth2
children0
last_payout2024-05-06 20:35:21
cashout_time1969-12-31 23:59:59
total_payout_value0.040 HBD
curator_payout_value0.040 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length8
author_reputation253,543,214,078,146
root_title"My Coding Quiz #57"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id133,225,572
net_rshares193,159,140,376
author_curate_reward""
vote details (1)
@tipu ·
<a href="https://tipu.online/hive_curator?miriannalis" target="_blank">Upvoted  &#128076;</a> (Mana: 0/75) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
properties (22)
authortipu
permlinkre-re-eniolw-scmfua-20240427t215521z
categoryhive-197685
json_metadata"{"app": "beem/0.24.26"}"
created2024-04-27 21:55:21
last_update2024-04-27 21:55:21
depth2
children0
last_payout2024-05-04 21:55:21
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_length218
author_reputation55,905,961,568,182
root_title"My Coding Quiz #57"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id133,176,606
net_rshares0
@stemsocial ·
re-eniolw-my-coding-quiz-57-20240427t185140260z
<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-57-20240427t185140260z
categoryhive-197685
json_metadata{"app":"STEMsocial"}
created2024-04-27 18:51:39
last_update2024-04-27 18:51:39
depth1
children0
last_payout2024-05-04 18:51:39
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,903,711,652,468
root_title"My Coding Quiz #57"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id133,170,987
net_rshares0