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.
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.
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茅.
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.