==================== Data types in Python ==================== =============================================================================== Data type Description and examples =============================================================================== integer signed integer, 32 bits, e.g., 2147483647 ------------------------------------------------------------------------------- float 64 bit double precision, e.g., 1.23 or 7.8e-28 ------------------------------------------------------------------------------- long integer arbitrarily large integer, e.g., trailing L, 234187626348292917L, 7L ------------------------------------------------------------------------------- octal integer base-8 integer, e.g., leading 0 as in 0177 ------------------------------------------------------------------------------- hexadecimal integer base-16 integer, e.g., leading 0x as in 0x9FC ------------------------------------------------------------------------------- complex real and imaginary parts, e.g., written as 3 + 4j or 1.23 - 0.0073j ------------------------------------------------------------------------------- character string ordered collection of characters, e.g., enclosed by pairs of ', or " characters ------------------------------------------------------------------------------- list ordered collection of objects, e.g., like [1,22,[321,'cow'],'horse'] ------------------------------------------------------------------------------- dictionary collection of associated key:data pairs e.g., like {'first':'alpha','last':'omega'} ------------------------------------------------------------------------------- tuples similar to lists, e.g., like ('hen','duck',('rabbit','hare'),'dog','cat') ------------------------------------------------------------------------------- file disk files e.g., as in: file1 = open('data.01','r'); data = file1.read() =============================================================================== =================================================== Data types in Python (based on data storage/access) =================================================== =============================================================================== Data type Description and examples =============================================================================== direct data is represented directly; numeric data types (long) integer, float, complex ------------------------------------------------------------------------------- sequence data contains other data; ordered and collected list, string, tuple ------------------------------------------------------------------------------- mapping data contains other data; not ordered but collected dictionary =============================================================================== ========================================== Data types in Python (based on mutability) ========================================== =============================================================================== Data type Description examples =============================================================================== mutable data values can be changed list, dictionary ------------------------------------------------------------------------------- immutable data values can not be changed numeric, string, tuple =============================================================================== ========================================================= Data types in Python (based on number of objects in data) ========================================================= =============================================================================== Data type Description examples =============================================================================== literal/scalar only one object can be stored string, numeric ------------------------------------------------------------------------------- container Various other objects can be stored list, tuple, dictionary =============================================================================== ============================== Data types in Python (Summary) ============================== =============================================================================== Data type Data model mutability access type =============================================================================== numeric literal no direct string literaal no sequence list container yes sequence tuple container no sequence dictionary container yes mapping ===============================================================================