My Coding Quiz #2

My Coding Quiz #2 👨‍💻🛠️🧩

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


What's your choice?

Solution to the previous quiz: 4. On line 1, the // operator corresponds to division and automatic rounding of the result to the nearest integer below. It means that the operation 11 // 2 produces 5. On line 2, the round function is a red herring, as it won't round anything. Line 3 performs the well-known modulo operation with the % operator, returning 1. Line 4 introduces the exponentiation operator**. Evaluating the previously computed and assigned values, you would have 5 raised to the power 1, giving 5, and subtract 1 from this, giving 4. So z is equal to 4, which is what is printed on the last line.

Congratulations to @gwajnberg, @bluerobo and @edb for coming up with the right answer!

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 #2 👨‍💻🛠️🧩

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


¿Cuál es tu elección?

Solución al quiz anterior: 4. En la línea 1 el operador // corresponde con la division y automático redondeo del resultado hacia el entero más cercano por debajo. Significa que la operación produce 5. En la línea dos, la función round es una pista falsa, pues no redondeará nada. La línea 3 ejecuta la operación de módulo bien conocida, dando como resultado 1. La línea presenta al operador de potenciación **. Al evaluar los valores calculados y asignados se tendría que 5 se eleva a la potencia 1, lo que da 5 y a esto se le resta 1 y da 4. Por lo tanto, z vale 4, que es lo que se imprime en la última línea.

¡Enhorabuena a @gwajnberg, @bluerobo y @edb por dar con la respuesta correcta!

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.



0
0
0.000
5 comments
avatar

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. 
 

0
0
0.000
avatar

That's 2+0=2.

Last time, I missed the automatic rounding of //, that's sneaky.

0
0
0.000
avatar

Yeah, programming languages have so many sneaky features even when you think you know them well. I'm going to post the answer to this quiz in a few hours :)

0
0
0.000