Ibuprofeno.py💊| #190: Explica este código Python

Explica este código Python

Dificultad: Fácil

x = lambda x: len(x.split())
print(type(x))

A. class <‘function’>

B. class <‘lambda’>

C. class <‘tuple’>

D. Error

Respuesta:
👉 A. class &…


This content originally appeared on DEV Community and was authored by Cristian Fernando

Explica este código Python

Dificultad: Fácil

x = lambda x: len(x.split())
print(type(x))
  • A. class <'function'>
  • B. class <'lambda'>
  • C. class <'tuple'>
  • D. Error

Respuesta:

👉 A. class <'function'>

Las funciones lambda de Python tienen una sintaxis mas compacta y sencilla de comprender, al ser anónimas es usual almacenar su valor de retorno en una variable, dicha variable será de tipo función y para llamar a la función podríamos hacer:

x = lambda x: len(x.split())
print(x("hola como estas"))


This content originally appeared on DEV Community and was authored by Cristian Fernando


Print Share Comment Cite Upload Translate Updates
APA

Cristian Fernando | Sciencx (2024-10-09T04:00:00+00:00) Ibuprofeno.py💊| #190: Explica este código Python. Retrieved from https://www.scien.cx/2024/10/09/ibuprofeno-py%f0%9f%92%8a-190-explica-este-codigo-python/

MLA
" » Ibuprofeno.py💊| #190: Explica este código Python." Cristian Fernando | Sciencx - Wednesday October 9, 2024, https://www.scien.cx/2024/10/09/ibuprofeno-py%f0%9f%92%8a-190-explica-este-codigo-python/
HARVARD
Cristian Fernando | Sciencx Wednesday October 9, 2024 » Ibuprofeno.py💊| #190: Explica este código Python., viewed ,<https://www.scien.cx/2024/10/09/ibuprofeno-py%f0%9f%92%8a-190-explica-este-codigo-python/>
VANCOUVER
Cristian Fernando | Sciencx - » Ibuprofeno.py💊| #190: Explica este código Python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/09/ibuprofeno-py%f0%9f%92%8a-190-explica-este-codigo-python/
CHICAGO
" » Ibuprofeno.py💊| #190: Explica este código Python." Cristian Fernando | Sciencx - Accessed . https://www.scien.cx/2024/10/09/ibuprofeno-py%f0%9f%92%8a-190-explica-este-codigo-python/
IEEE
" » Ibuprofeno.py💊| #190: Explica este código Python." Cristian Fernando | Sciencx [Online]. Available: https://www.scien.cx/2024/10/09/ibuprofeno-py%f0%9f%92%8a-190-explica-este-codigo-python/. [Accessed: ]
rf:citation
» Ibuprofeno.py💊| #190: Explica este código Python | Cristian Fernando | Sciencx | https://www.scien.cx/2024/10/09/ibuprofeno-py%f0%9f%92%8a-190-explica-este-codigo-python/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.