create account

My Coding Quiz #11 (Javascript edition) by eniolw

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

<center><h2>My Coding Quiz #11 👨‍💻🛠️🧩</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/DQmTNWcY3wDVfRzUswjXVwqtK6AF6UwuRDE92Gp2v6Lf12D/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-10">previous quiz</a>:</b> <b>ab ['A', 'B', 'C']</b>. Line 1 creates a variable <code>m</code> with a string <b>'abc'</b>. Line 2 creates an anonymous string based on <code>m</code>, but with uppercase characters: <b>'ABC'</b>.</p>

<p>With this string, in turn, a list <code>n</code> is created where each element of the list consists of each character of the given string. The content of the <code>n</code> list would be <b>['A', 'B', 'C']</b>. Python can create lists like this in many ways and here it does it with the <code>*</code> as an <i>unpacking operator</i> (yes, once again, the <code>*</code> has yet another distinctive use in Python).</p>

<p>Line 3 has the rest of the quiz gist: The <code>:</code> operator applied to a list or string in this way is used to do <i>slicing</i>. First the string <code>m</code> is sliced from the beginning to exclusive position 2, i.e. only indices 0 and 1 will be extracted, resulting in the value <b>'ab'</b>.</p>

<p>Then the <code>n</code> list is sliced from the beginning to exclusive position 4. This list is not that big, since its length is 3, but Python is made to do slicing safely, that is, it will only slice up to the actual limit of the list, even if a larger value is specified for it. This will prevent overflow or similar errors. Therefore, what is printed in line 3 is <b>ab ['A', 'B', 'C']</b>.</p>

<p>How did you like it? What was the essence of the quiz for you? Probably the unpacking operator and the slicing operator. But this is not all that these operators can offer. @splash-of-angs63 solved this quiz. Great!</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>,  <a href="/created/hive-153850">Hive Learners</a> and others.</p>

<hr>

<center><h2>Mi Quiz de Programación #11 👨‍💻🛠️🧩</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/DQmZFLyUjdUDygxiuXEFpuwB8smutrKPH2Bd84uvnCaDPe6/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-10">quiz anterior</a>:</b> <b>ab ['A', 'B', 'C']</b>. La línea 1 crea una variable <code>m</code> con una cadena de caracteres <b>'abc'</b>. La línea 2 crea una cadena anónima basada en <code>m</code>, pero con caracteres en mayúsculas: <b>'ABC'</b>.</p>

<p>Con esta cadena, a su vez, se crea una lista <code>n</code> donde cada elemento de la lista está formado por cada caracter de la cadena dada. El contenido de la lista <code>n</code> sería <b>['A', 'B', 'C']</b>. Python puede crear listas como estas de muchas maneras y aquí lo hace con el <code>*</code> como un <i>operador de desempacado</i> (sí, una vez más, el <code>*</code> tiene otro uso distintivo más en Python).</p>

<p>La línea 3 posee el resto de la esencia del quiz: El operador <code>:</code> aplicado a una lista o cadena de esta manera sirve para hacer <i>rebanado</i>. Primero se rebana la cadena <code>m</code> desde el principio hasta la posición 2 no exclusiva, es decir, que solo se extraerán los índices 0 y 1, lo que se traduce en el valor <b>'ab'</b>.</p>

<p>Luego se rebana la lista <code>n</code> desde el principio hasta la posición 4 no exclusiva. Esta lista no es tan grande, pues su longitud es de 3, pero Python está hecho para hacer el rebanado de manera segura, es decir, que solo rebanará hasta el límite real de la lista, aún cuando se le haya especificado un valor mayor. Esto prevendrá errores de desbordamiento o similares. Por tanto, lo impreso en la línea 3 es <b>ab ['A', 'B', 'C']</b>.</p>

<p>¿Qué te ha parecido? ¿Cuál fue la esencia del quiz para ti? Probablemente el operador de desempaquetado y el operador de rebanado. Pero esto no es todo lo que estos operadores pueden ofrecer. @splash-of-angs63 resolvió este quiz. ¡Qué bien!</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>, <a href="/created/hive-153850">Hive Learners</a> y otras.</p>

</div>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 481 others
properties (23)
authoreniolw
permlinkmy-coding-quiz-11-javascript
categoryhive-196387
json_metadata"{"image": ["https://images.ecency.com/DQmTNWcY3wDVfRzUswjXVwqtK6AF6UwuRDE92Gp2v6Lf12D/quiz_img_en.png", "https://images.ecency.com/DQmZFLyUjdUDygxiuXEFpuwB8smutrKPH2Bd84uvnCaDPe6/quiz_img_es.png"], "thumbnails": ["https://images.ecency.com/DQmTNWcY3wDVfRzUswjXVwqtK6AF6UwuRDE92Gp2v6Lf12D/quiz_img_en.png", "https://images.ecency.com/DQmZFLyUjdUDygxiuXEFpuwB8smutrKPH2Bd84uvnCaDPe6/quiz_img_es.png"], "tags": ["hive-196387", "programming", "coding", "python", "technology", "neoxian", "proofofbrain", "creativecoin", "chessbrothers", "spanish"], "description": "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.0.35-vision", "format": "markdown+html"}"
created2023-07-31 09:10:18
last_update2023-07-31 09:10:18
depth0
children6
last_payout2023-08-07 09:10:18
cashout_time1969-12-31 23:59:59
total_payout_value7.298 HBD
curator_payout_value7.204 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,637
author_reputation255,044,102,627,024
root_title"My Coding Quiz #11 (Javascript edition)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id125,797,899
net_rshares31,585,247,942,603
author_curate_reward""
vote details (545)
@splash-of-angs63 ·
As y is a local variable inside the function ‘quiz’ so it can’t be accessed outside of it. The code will throw an error. 
properties (22)
authorsplash-of-angs63
permlinkre-eniolw-2023731t23137106z
categoryhive-196387
json_metadata{"tags":["hive-196387","programming","coding","python","technology","neoxian","proofofbrain","creativecoin","chessbrothers","spanish"],"app":"ecency/3.0.35-vision","format":"markdown+html"}
created2023-07-31 17:43:09
last_update2023-07-31 17:43:09
depth1
children1
last_payout2023-08-07 17:43: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_length121
author_reputation49,712,805,563,209
root_title"My Coding Quiz #11 (Javascript edition)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id125,807,735
net_rshares0
@eniolw ·
We'll see about that :)
👍  
properties (23)
authoreniolw
permlinkre-splash-of-angs63-2023731t223724366z
categoryhive-196387
json_metadata{"tags":["hive-196387","programming","coding","python","technology","neoxian","proofofbrain","creativecoin","chessbrothers","spanish"],"app":"ecency/3.0.35-vision","format":"markdown+html"}
created2023-08-01 02:37:24
last_update2023-08-01 02:37:24
depth2
children0
last_payout2023-08-08 02:37:24
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_length23
author_reputation255,044,102,627,024
root_title"My Coding Quiz #11 (Javascript edition)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id125,821,185
net_rshares3,916,203,183
author_curate_reward""
vote details (1)
@stemsocial ·
re-eniolw-my-coding-quiz-11-javascript-20230801t055729253z
<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-11-javascript-20230801t055729253z
categoryhive-196387
json_metadata{"app":"STEMsocial"}
created2023-08-01 05:57:30
last_update2023-08-01 05:57:30
depth1
children0
last_payout2023-08-08 05:57: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,915,413,852,146
root_title"My Coding Quiz #11 (Javascript edition)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id125,827,146
net_rshares0
@yonnathang ·
@tipu curate 6
properties (22)
authoryonnathang
permlinkre-eniolw-2023731t10010743z
categoryhive-196387
json_metadata{"tags":["hive-196387","programming","coding","python","technology","neoxian","proofofbrain","creativecoin","chessbrothers","spanish"],"app":"ecency/3.0.35-vision","format":"markdown+html"}
created2023-07-31 14:00:12
last_update2023-07-31 14:00:12
depth1
children2
last_payout2023-08-07 14:00: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_length14
author_reputation377,650,733,039,559
root_title"My Coding Quiz #11 (Javascript edition)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id125,802,887
net_rshares0
@eniolw ·
Gracias.
properties (22)
authoreniolw
permlinkre-yonnathang-2023731t22375998z
categoryhive-196387
json_metadata{"tags":["hive-196387","programming","coding","python","technology","neoxian","proofofbrain","creativecoin","chessbrothers","spanish"],"app":"ecency/3.0.35-vision","format":"markdown+html"}
created2023-08-01 02:37:06
last_update2023-08-01 02:37:06
depth2
children0
last_payout2023-08-08 02:37: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_length8
author_reputation255,044,102,627,024
root_title"My Coding Quiz #11 (Javascript edition)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id125,821,179
net_rshares0
@tipu ·
<a href="https://tipu.online/hive_curator?yonnathang" target="_blank">Upvoted  &#128076;</a> (Mana: 0/72) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
properties (22)
authortipu
permlinkre-re-eniolw-2023731t10010743z-20230731t140019z
categoryhive-196387
json_metadata"{"app": "beem/0.24.26"}"
created2023-07-31 14:00:18
last_update2023-07-31 14:00:18
depth2
children0
last_payout2023-08-07 14:00:18
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,914,702,009,771
root_title"My Coding Quiz #11 (Javascript edition)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id125,802,891
net_rshares0