Python: ranges and Lambda

evens_to_50 = [i for i in range(51) if i % 2 == 0]print evens_to_5
dobles_por_3 = [x*2 for x in range(1,6) if (x*2) % 3 == 0]
# Completa la siguiente línea. Usá la línea de arriba como ayuda.
cuadrados_pares = [x*2 for x in range(1,12) if (x*2) % 2 == 0] 
print cuadrados_pares

mi_lista = range(16)
print filter(lambda x: x % 3 == 0, mi_lista)

lenguajes = ["HTML", "JavaScript", "Python", "Ruby"]
print filter(lambda i: i == "Python" , lenguajes)

incomprensible = "!XeXgXaXsXsXeXmX XtXeXrXcXeXsX XeXhXtX XmXaX XI"
mensaje = filter(lambda x: x!='X', incomprensible[::-1])print mensaje

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s