“Mapa w Pythonie” Kod odpowiedzi

Funkcja map w Pythonie

# Python program to demonstrate working 
# of map. 
  
# Return double of n 
def addition(n): 
    return n + n 
  
# We double all numbers using map() 
numbers = (1, 2, 3, 4) 
result = map(addition, numbers) 
print(list(result))
Bright Butterfly

Mapa w Pythonie

# Python program to demonstrate working 
# of map. 
  
# Return double of n 
def addition(n): 
    return n + n 
  
# We double all numbers using map() 
numbers = (1, 2, 3, 4) 
result = map(addition, numbers) 
print(list(result))
# result [2, 4, 6, 8]
Grumpy Gull

Python Map ()

# Program to double each item in a list using map()

my_list = [1, 5, 4, 6, 8, 11, 3, 12]

new_list = list(map(lambda x: x * 2 , my_list))

print(new_list)
SAMER SAEID

Kiedy używać funkcji mapy w Pythonie

#The map function is used to do a certain function to a certain iterable
#It takes a function and an iterable
numbers = [1,2,3,4,5,6,7,8,9,10]
x = map(lambda nom : nom*nom, numbers)
print(list(x))
#So here my function is the lambda and the iterable is the numbers list
#And with this I apply nom*nom to every item to the list
# if I didn't put the list function before x it would print map object at .....
Karim Radwan

Mapa Fuo Python

lista =  [1, 2, -3, 4, 5, -9]
def quadrado(n):
    return n*n
 
map(quadrado, lista)
[1, 4, 9, 16, 25, 81]
Kind Kookaburra

Funkcja map w Pyhton

# Python program to demonstrate working
# of map.
  
# Return double of n
def addition(n):
    return n + n
  
# We double all numbers using map()
numbers = (1, 2, 3, 4)
result = addition(numbers)
print(list(result))
meet desai

Odpowiedzi podobne do “Mapa w Pythonie”

Pytania podobne do “Mapa w Pythonie”

Więcej pokrewnych odpowiedzi na “Mapa w Pythonie” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu