“Peta dalam Python 3” Kode Jawaban

fungsi peta dalam python

# 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

Peta dalam Python

# 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

Funo Map 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

Peta dalam Python 3

from multiprocessing import Pool

def test( v ):
    print(v)
    return v

if __name__ == '__main__':
    with Pool(2) as p:
        print(p.map(test, range(5)))
Xerothermic Xenomorph

Sintaks fungsi peta python

map(fun, iter)
Outrageous Ostrich

Jawaban yang mirip dengan “Peta dalam Python 3”

Pertanyaan yang mirip dengan “Peta dalam Python 3”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya