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

Explica este código Python

Dificultad: Intermedio

lista = [6,7,8,9,10]

res_filter = list(filter(lambda x: x > 8 ,lista))
print(res_filter)

A. [9, 10]

B. [6, 7, 8, 9, 10]

C. [1, 2, 3, 4, 5, 6, 7]

D. [8, 9, 10…


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

Explica este código Python

Dificultad: Intermedio

lista = [6,7,8,9,10]

res_filter = list(filter(lambda x: x > 8 ,lista))
print(res_filter)
  • A. [9, 10]
  • B. [6, 7, 8, 9, 10]
  • C. [1, 2, 3, 4, 5, 6, 7]
  • D. [8, 9, 10]

Respuesta:

👉 A. [9, 10]

filter() se encarga de hacer un filtrado de un iterable, en nuestro ejemplo aplicamos la condición x > 8 a toda la lista lista, entonces regresamos una nueva lista que solo tenga los items que cumplan con la condición dada.


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-07-16T11:00:00+00:00) Ibuprofeno.py💊| #142: Explica este código Python. Retrieved from https://www.scien.cx/2024/07/16/ibuprofeno-py%f0%9f%92%8a-142-explica-este-codigo-python/

MLA
" » Ibuprofeno.py💊| #142: Explica este código Python." Cristian Fernando | Sciencx - Tuesday July 16, 2024, https://www.scien.cx/2024/07/16/ibuprofeno-py%f0%9f%92%8a-142-explica-este-codigo-python/
HARVARD
Cristian Fernando | Sciencx Tuesday July 16, 2024 » Ibuprofeno.py💊| #142: Explica este código Python., viewed ,<https://www.scien.cx/2024/07/16/ibuprofeno-py%f0%9f%92%8a-142-explica-este-codigo-python/>
VANCOUVER
Cristian Fernando | Sciencx - » Ibuprofeno.py💊| #142: Explica este código Python. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/16/ibuprofeno-py%f0%9f%92%8a-142-explica-este-codigo-python/
CHICAGO
" » Ibuprofeno.py💊| #142: Explica este código Python." Cristian Fernando | Sciencx - Accessed . https://www.scien.cx/2024/07/16/ibuprofeno-py%f0%9f%92%8a-142-explica-este-codigo-python/
IEEE
" » Ibuprofeno.py💊| #142: Explica este código Python." Cristian Fernando | Sciencx [Online]. Available: https://www.scien.cx/2024/07/16/ibuprofeno-py%f0%9f%92%8a-142-explica-este-codigo-python/. [Accessed: ]
rf:citation
» Ibuprofeno.py💊| #142: Explica este código Python | Cristian Fernando | Sciencx | https://www.scien.cx/2024/07/16/ibuprofeno-py%f0%9f%92%8a-142-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.