python map

Solutions on MaxInterview for python map by the best coders in the world

showing results for - "python map"
Milla
23 Aug 2016
1# Python program to demonstrate working 
2# of map. 
3  
4# Return double of n 
5def addition(n): 
6    return n + n 
7  
8# We double all numbers using map() 
9numbers = (1, 2, 3, 4) 
10result = map(addition, numbers) 
11print(list(result))
Debora
02 Jul 2018
1#generate a list from map iterable with lambda expression
2list( map(lambda x: x*2, numeros) )
Anna
07 Jan 2020
1def calculateSquare(n):
2    return n*n
3
4
5numbers = (1, 2, 3, 4)
6result = map(calculateSquare, numbers)
7print(result)
8
9# converting map object to set
10numbersSquare = list(result)
11print(numbersSquare)
Nathaniel
01 Apr 2019
1items = [1, 2, 3, 4, 5]
2squared = list(map(lambda x: x**2, items))
3
Paula
22 Jan 2018
1map(function_to_apply, list_of_inputs)
2
Sofia
20 Aug 2016
1lista =  [1, 2, -3, 4, 5, -9]
2def quadrado(n):
3    return n*n
4 
5map(quadrado, lista)
6[1, 4, 9, 16, 25, 81]