Python Programming Tutorial - 50 - map

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Let's use Lambda :)

print(list(map(lambda x: x*2, [10, 30, 75])))

eyalpery
Автор

This is actually the best python tutorial series I ever found.he makes concepts so simple and explain things so that even a noob can understand. The best thing is he explains things that other tutorial skips and those are often what a beginner would be troubled with. What an amazing job! I can't wait to check out his other tutorials.

rong
Автор

Further topics you could cover:
-Regular Expressions
-Networking
-CGI Programming
-Database Interactions
-optparse
-Generators
-Iterators
-List comprehension
-Decorators (Including standard decorators built into Python, e.g @staticmethod)
-super() function
-enumerate() function
-sockets
-C extensions
-Templates
-Other modules part of Python's standard library (hashlib, pickle etc)

Third party libraries you could teach:
-Twisted (Event driven networking library)
-Django (Web framework - like Flask, but better imo)

Good luck! Most of these topics lack good videos, so it would be great if you could cover them

kalaivanysivalingam
Автор

Damn the views sure dropped to measly 50k. This awesome tutorial deserves more views.

nitinpandey
Автор

Really fast really simple explanation! thank you

joeturk
Автор

This forloop is half the work and twice as easy. So for what case would you need to use a map function?



income = [10, 30, 75]

for e in income:
e *= 2
print(e)

vs

income = [10, 30, 75]

def double_money(dollars):
return dollars * 2

new_income = list(map(double_money, income))
print(new_income)

jelleburggraaf
Автор

Is there any bucky's student who fall in love with his voice.xD lol.

iyaasawa-chanyamete
Автор

I typed the code :
income = [10, 20, 30]

def func(dollar):
print(dollar* 2)

list(map(func, income))

AND IT GAVE ME THE CORRECT ANSWER!!!! DON'T KNOW HOW???

godishelping
Автор

3:00 lista_przekształcona = list(map(przekształcenie, lista)) - prawdopodobnie nie można robic działań na listach

pawebrysch
Автор

or you can do something like this:

nub=[45, 23, 23, 89, 456, 789, 123, 890]

def magic_number(number):
magic= number*2+10/2
print(magic)


list(map(magic_number, nub))

flow
Автор

Is anyone having issues with importing AF_PACKET from sockets? PyCharm isn't recognizing it for me.

jackscott
Автор

I wrote a lambda function instead of defining one.

DavidAnatolie
Автор

I played with the above in idle, it seems that you don't need list in front of the map function, as map will return a list eg
>>> income=[10, 20, 30]
>>> def d(d):
return d*2

>>> ans=map(d, income)
>>> type(ans)
<type 'list'>
>>> ans
[20, 40, 60]
>>>

nwood
Автор

Not clear tutorial, maybe this is more clear.

def myfunc(n):
return len(n)

x = map(myfunc, ('apple', 'banana', 'cherry'))

You are iterating values and applying the function to each of them and put them in a list

impossiblehousemarylandsta
Автор

how to write this same code with "for" command??... pls let me know quickly

Naifth
Автор

why not:
new_income = [double_money(i) for i in income]

Isaac-gpdq