Se la funzione type() ha un solo argomento allora restituisce il tipo dell’argomento.
I tipi predefiniti, in ordine alfabetico
Codice | Output | ? |
---|---|---|
type(True) | <class 'bool'> | boolen (value) |
type(1024j) | <class 'complex'> | complex (number) |
type({'a':1024}) | <class 'dict'> | dictionary |
type(1024.0) | <class 'float'> | floating point (number) |
type(1024) | <class 'int'> | integer (number) |
type([1,0,2,4]) | <class 'list'> | list |
type(range(1024)) | <class 'range'> | range |
type({1,0,2,4}) | <class 'set'> | set |
type("Arcobaleno") | <class 'str'> | string |
type((1,0,2,4)) | <class 'tuple'> | tuple |
Ci sono tipi aggiuntivi nei moduli nativi, nei moduli di terze parti, nelle classi definite dall’utente…