My Coding Quiz #35

in #hive-150329last year

My Coding Quiz #35 👨‍💻🛠️🧩

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 simple and fun way. If you want to learn more about it visit my blog here on Hive and the first post where I introduced it.

Without further ado, here's the riddle...




Quiz
By @eniolw


What's your choice?

Solution to the previous quiz: False. Line 1 creates a numeric variable num_block with the integer value one million (1,000,000).

The fact that it is written with underscores included in the numeric literal is irrelevant. The purpose of these underscores is to improve the readability of the number in the code for programmers. They are new in Python 3.6, which means that it has been around for a while and the feature exists in other languages as well. If you didn't know about it, it's been a waste, as it's quite useful.

Line 2 also creates a numeric variable tid and is worth 100,000. Note that the underscores here do not improve readability much, as we are not using them as expected, which is as thousand-unit separators. However, the point is that it does not create any syntax problems and its use is flexible.

I originally wanted the numeric literal for tid to have six zeros, so that it would be the same value as the num_block variable, but it looks like I accidentally "ate" a zero.

Anyway, line 3 compares both values, which are different, so _v is false and is what is printed at the end. We see that _v also has an underscore. In Python underscores have a few good uses. We'll see more of them later; maybe.


If you want to blog about computer science and programming content, I invite you to join Hive and participate in its communities, such as STEM-social, Develop Spanish, Programming & Dev and others.


Mi Quiz de Programación #35 👨‍💻🛠️🧩

Bienvenido a mi nueva serie de Quizzes de Programación, 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 mi blog aquí en Hive y el primer post donde la presenté.

Sin más preámbulos, he aquí el acertijo...




Quiz
Por @eniolw


¿Cuál es tu elección?

Solución al quiz anterior: False. La línea 1 crea una variable numérica num_block con el valor entero un millón (1.000.000).

El hecho de que esté escrito con guiones bajos incluidos en el literal numérico es irrelevante. El propósito de estos guiones bajos es mejorar la legibilidad del número en el código para los programadores. Son nuevas en Python 3.6, lo que significa que existe desde hace un tiempo y la característica también existe en otros lenguajes. Si no lo sabías, ha sido un desperdicio, ya que es bastante útil.

La línea 2 también crea una variable numérica tid y vale 100.000. Tenga en cuenta que los guiones bajos aquí no mejoran mucho la legibilidad, ya que no los usamos como se esperaba, que es como separadores de mil unidades. Sin embargo, la cuestión es que no crea ningún problema de sintaxis y su uso es flexible.

Originalmente quería que el literal numérico de tid tuviera seis ceros, para que tuviera el mismo valor que la variable num_block, pero parece que accidentalmente "me comí" un cero.

De todos modos, la línea 3 compara ambos valores, que son diferentes, por lo que _v es falso y es lo que se imprime al final. Vemos que _v también tiene un guión bajo. En Python, los guiones bajos tienen algunos buenos usos. Veremos más de ellos más adelante; quizás.


Si quieres bloguear sobre contenido informático y de programación, te invito a unirte a Hive y participar en sus comunidades, tales como STEM-social, Develop Spanish, Programming & Dev y otras.

Sort:  

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord 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.