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: 3. First a list called songs is created with four song titles. If you are familiar with Aurora Aksnes, you will probably recognise these song names.
Then a second list called played is created containing 'Soft ' 'universe'. There is no syntactic error or missing comma or anything similar here. We've already discussed that these strings isolated in this way are automatically concatenated by Python, so they really consist of the single string 'Soft universe'.
We then do a set difference using the - operator instead of the difference method. This operation compares two sets and creates a new one with those items that are in the first set, but are not in the second set.
In our example, we see that the items 'Little boy in the grass', 'It happened quiet' and 'Forgotten love' are in songs, but not in played, so they constitute the newly created anonymous set. This set is converted into a list and from it we are interested in its size, which is 3.
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: 3. Primero se crea una lista llamada songs con cuatro t铆tulos de canciones. Si est谩s familiarizado con Aurora Aksnes, probablemente reconocer谩s los nombres de estas canciones.
Luego se crea una segunda lista llamada played que contiene 'Soft ' 'universe'. Aqu铆 no hay ning煤n error sint谩ctico ni falta una coma ni nada similar. Ya hemos comentado que Python concatena autom谩ticamente estas cadenas aisladas de esta manera, por lo que en realidad consisten en una sola cadena: 'Soft universe'.
Luego hacemos una diferencia de conjuntos usando el operador - en lugar del m茅todo difference. Esta operaci贸n compara dos conjuntos y crea uno nuevo con aquellos elementos que est谩n en el primer conjunto, pero no en el segundo.
En nuestro ejemplo, vemos que los elementos 'Little boy in the grass', 'It happened quiet' y 'Forgotten love' est谩n en songs, pero no en played, por lo que constituyen el conjunto an贸nimo reci茅n creado. Este conjunto se convierte en una lista y de ella nos interesa su tama帽o, que es 3.
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.