My Coding Quiz #21

in #hive-196387last year

My Coding Quiz #21 👨‍💻🛠️🧩

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: Science Tech Engineering Math. Line 1 creates the string p = "science,tech,engineering,math" on which the operations will be performed.

Line 2 splits the string into a list using the well-known split method. Since the argument is ",", w will consist of ['science', 'tech', 'engineering', 'math']. Then we modify the last element of w by making it capital letters with upper, so that w becomes ['science', 'tech ', 'engineering', 'MATH'].

Then, we apply join to obtain a new string based on the list w and specifying a blank character separator, thus obtaining 'science tech engineering MATH' which is the value of n.

Finally we print n.title(). What this curious method does is make the first letter of each word capital and the rest lower case, as in a heading. Hence we get Science Tech Engineering Math at the end.

These split and join operations are extremely common when programming in Python. The title method, for its part, is not so common, but it can be very useful.


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

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: Science Tech Engineering Math. La línea 1 crea el string p = "science,tech,engineering,math" sobre el cual se operará.

La línea 2 descompone el string en una lista usando el conocido método split. Como el argumento es ",", w consistirá en ['science', 'tech', 'engineering', 'math']. Luego modificamos el último elemento de w haciendolo letras mayúsculas con upper, con lo cual w queda en ['science', 'tech', 'engineering', 'MATH'].

Luego, aplicamos join para obtener un nuevo string con base en la lista w y especificando un separador de caracter en blanco, obteniendo así 'science tech engineering MATH' que es el valor de n.

Finalmente imprimimos n.title(). Este curioso método lo que hace es hacer que la primera letra de cada palabra sea mayúscula y las demás minúsculas, como en un encabezado. De allí que obtengamos Science Tech Engineering Math al final.

Estas operaciones con split y join son extremadamente comunes cuando se programa en Python. El método title por su parte no es tan comun, pero si puede ser muy útil.


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. 
 

How I wish I haven't given up on my coding years ago. I was frustrated learning it years ago so I gave up 😔

That's a shame. You surely will find something that you like better and can handle more easily.

Yea I discovered I love crypto and forex trading since then