“Karte in Python 3” Code-Antworten

Kartenfunktion in 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

Karte in 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

Karte in 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

Python Map Function Syntax

map(fun, iter)
Outrageous Ostrich

Ähnliche Antworten wie “Karte in Python 3”

Fragen ähnlich wie “Karte in Python 3”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen