Anteprima
Vedrai una selezione di 1 pagina su 5
Proprietà liste array set tuple e dictionary  Pag. 1
1 su 5
D/illustrazione/soddisfatti o rimborsati
Disdici quando
vuoi
Acquista con carta
o PayPal
Scarica i documenti
tutte le volte che vuoi
Estratto del documento

La lista è una raccolta ordinata e modificabile. Consente membri

duplicati.

Tuple è una collezione ordinata e immutabile. Consente membri

duplicati.

Set è una raccolta non ordinata, immutabile* e non indicizzata. Nessun

membro duplicato.

Il dizionario è una raccolta ordinata** e modificabile. Nessun membro

duplicato.

There are four collection data types in the Python programming

language:

List is a collection which is ordered and changeable. Allows duplicate

members.

Tuple is a collection which is ordered and unchangeable. Allows duplicate

members.

Set is a collection which is unordered, unchangeable*, and unindexed. No

duplicate members.

Dictionary is a collection which is ordered** and changeable. No duplicate

members.

LISTE SET TUPLE DICTIONARY

ORDINATA: NON ORDINATA: ORDINATA: ORDINATA:

When we say that Unordered When we say that When we say that

lists are ordered, it means that the tuples are dictionaries are

means that the items in a set do ordered, it means ordered, it means

items have a not have a that the items that the items

defined order, and defined order. have a defined have a defined

that order will not Set items can order, and that order, and that

change. appear in a order will not order will not

If you add new different order change. change.

items to a list, the every time you

new items will be use them,

placed at the end

of the list.

MODIFICABILE : SI NON NON MODIFICABILE : SI

PUò AGGIUNGERE MODIFICABILE MODIFICABILE Dictionaries are

si può comunque

TOGLIERE E ANCHE Tuples are changeable,

eliminare un

MODIFICARE GLI unchangeable, meaning that we

elemento ed

ELEMENTI meaning that we can change, add

inserirne un altro cannot change, or remove items

ma non modificare

The list is add or remove after the

gli elementi

changeable, items after the dictionary has

meaning that we tuple has been been created.

Set items are

can change, add, created.

unchangeable,

and remove meaning that we

items in a list cannot change the

after it has been items after the set

created. has been created.

Once a set is

created, you

cannot change its

items, but you can

remove items and

add new items.

LISTE SET TUPLE DICTIONARY

AMMETTE NON AMMETTE AMMETTE NON AMMETTE

DUPLICATI: DUPLICATI: DUPLICATI: DUPLICATI:

Since lists are Sets cannot have Since tuples are Dictionaries

indexed, lists can two items with indexed, they cannot have two

have items with the same value. can have items items with the

the same value with the same same key:

value:

Sintassi: Sintassi: un SET è Sintassi: Una Sintassi:

mia_lista = [1, 2, definito TUPLA si Dictionaries are

3] O list() attraverso costruisce written with curly

parentesi graffe usando le brackets, and

{} o il costruttore parentesi tonde have keys and

"set()": (), ad esempio: values:

• mytuple = thisdict = {

("north", "south", "brand": "Ford",

"east", "ovest") "model":

"Mustang",

"year": 1964

}

oltre alle

parentesi quadre

si può

usare il metodo

get()

print(mydictiona

ry.get("brand"))

Dettagli
Publisher
A.A. 2023-2024
5 pagine
SSD Scienze matematiche e informatiche INF/01 Informatica

I contenuti di questa pagina costituiscono rielaborazioni personali del Publisher ibty_05 di informazioni apprese con la frequenza delle lezioni di Informatica e studio autonomo di eventuali libri di riferimento in preparazione dell'esame finale o della tesi. Non devono intendersi come materiale ufficiale dell'università Università degli Studi di Milano - Bicocca o del prof Candellieri Antonio.