My Coding Quiz #30

My Coding Quiz #30 馃懆鈥嶐煉火煕狅笍馃З

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: True. This quiz is no mystery and is basically a nod to the previous edition, which dealt with passing by reference.

We start by defining a local variable var and then a function func that takes a parameter also called var and modifies it inside. When the function func is called on line 4, the previously created local variable var, whose value is True, is passed to it. After returning from the function, the value of var remains True because it was a copy pass, that is, both var variables are different.

As for the semicolons in the script, they are completely unusual in Python, but not invalid, so they do not generate a syntax error. In fact, they can prove useful if you want to write several instructions on the same line.


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 #30 馃懆鈥嶐煉火煕狅笍馃З

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: True. Este quiz no es ning煤n misterio y b谩sicamente es un gui帽o a la edici贸n anterior, que trataba del paso por referencia.

Comenzamos definiendo una variable local var y luego una funci贸n func que toma un par谩metro tambi茅n llamado var y lo modifica en su interior. Cuando la funci贸n func es llamada en la l铆nea 4, se le pasa la variable local var previamente creada, cuyo valor es True. Tras regresar de la funci贸n, el valor de var se mantiene en True por cuanto fue un pase de copia, es decir, ambas variables var son diferentes.

En cuanto a los puntos y coma en el script, son completamente inusuales en Python, pero no inv谩lidos, por lo que no generan error de sintaxis. De hecho, pueden probar su utilidad si quieres escribir varias instrucciones en una misma l铆nea.


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.

H2
H3
H4
3 columns
2 columns
1 column
6 Comments