My Coding Quiz #31

in #hive-16932110 months ago

My Coding Quiz #31 👨‍💻🛠️🧩

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: <class 're.Match'>. We start by importing the re module which is used to work with regular expressions. Then we create a string u representing a URL.

Line 3 contains the heart of the matter: it uses the search function of the re module to search for a / character in the given string u. Since that character does exist, the function will return an object of the re.Match class.

You may wonder why from the class re.Match if the re.search function was used but not the re.match function, shouldn't it be an object of the class re.Search? Well, this class does not exist. The re.Match class was defined to represent these searches and in fact it has a number of useful and powerful methods and properties, such as group and span.

Also, it is important to keep in mind that the operation does not return a list or a tuple, since a search of all matches was not performed; that would be what the re.findall function would return, i.e., a list with all matches. Instead, re.search only looks for the first match and that's it.

Although we do not need to know the type of the object returned by re.search, knowing it demonstrates an advanced mastery of the language and even knowing without hesitation that it does not return a list or a tuple is definitely a basic knowledge that we should have.


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

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: <class 're.Match'>. Comenzamos importando el módulo re que se utiliza para trabajar con expresiones regulares. Luego creamos una cadena u que representa una URL.

La línea 3 contiene el meollo del asunto: utiliza la función search del módulo re para buscar un carácter / en el cadena dada u. Como ese carácter existe, la función devolverá un objeto de la clase re.Match.

Te preguntarás por qué desde la clase re.Match si se usó la función re.search pero no la función re.match, ¿No debería ser un objeto de la clase re.Search? Bueno, esta clase no existe. La clase re.Match se definió para representar estas búsquedas y, de hecho, tiene varios métodos y propiedades útiles y potentes, como group y span.

Además, es importante tener en cuenta que la operación no devuelve una lista o una tupla, ya que no se realizó una búsqueda de todas las coincidencias; eso sería lo que devolvería la función re.findall, es decir, una lista con todas las coincidencias. En cambio, re.search sólo busca la primera coincidencia y listo.

Aunque no necesitamos saber el tipo de objeto devuelto por re.search, saberlo demuestra un dominio avanzado del lenguaje e incluso saber sin dudarlo que no devuelve una lista o una tupla es definitivamente un conocimiento básico que deberíamos tener.


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:  

@tipu curate 8

This is so lovely and I believe will help improve the brain

Thanks!

You are welcome

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. 
 

Any firm that wants to succeed must first assemble a strong team of software developers, and in this process, software and mobile app development experience are critical components to acknowledge. A proficient software development team website is essential to realizing the goals of a startup. The foundation of creative solutions that meet the objectives of the company and its clients is frequently comprised of mobile apps and custom software. Startups can differentiate themselves in the market by creating scalable and user-friendly applications with the correct team in place.