Advanced functions Flashcards

1
Q

Advanced functions
- Elenco

A
  • lambda
  • map
  • filter
  • sorted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Andvanced functions
- lambda

A

lambda : funzioni in una sola riga

→ successor = lambda x : x+1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Andvanced functions
- map

A

map : applica funzione a lista

→ map(funzione, lista)

→ squared = map(lambda n:n**2, lista_numeri)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Andvanced functions
- filter

A

filter : crea lista da funzione su lista

→ filter(funzione, lista)

→ c = [‘a’,’b’,’ab’,’ac’,’d’]
r = list(filter(lambda x:x.startswith(‘a’),c)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Andvanced functions
- sorted

A

sorted: ordina lista

→ sorted(lista, funzione)

→ sorted(lista, lambda x: -x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly