Types

--Originally published at Fundamentos de Programación

Hello guys! This is probably really basic after all this time but I just noticed that I didn´t write a post about types for Python.

So let’s begin answering what are types? There are just a classification of data that tells the interpreter how you intend to  use the data.

wwlnamr_700wa_0

So let’s see which ones are the basic types in python:

types.NoneType
The type of None.

types.BooleanType
The type of the bool values True and False; alias of the built-in bool.

types.IntType
The type of integers (e.g. 1); alias of the built-in int.

types.LongType
The type of long integers (e.g. 1L); alias of the built-in long.

types.FloatType
The type of floating point numbers (e.g. 1.0); alias of the built-in float.

types.StringType
The type of character strings (e.g. 'Spam'); alias of the built-in str.

types.TupleType
The type of tuples (e.g. (1, 2, 3, 'Spam')); alias of the built-in tuple.

types.ListType
The type of lists (e.g. [0, 1, 2, 3]); alias of the built-in list.

types.DictType
The type of dictionaries (e.g. {'Bacon': 1, 'Ham': 0}); alias of the built-in dict.

pm0aarl_700wa_0

There are of course more, but this are the ones you absoluteley need to  know.

Here is a very explicit video on data types:

 

Follow me on twitter @danigguemez

Sources: https://docs.python.org/2/library/types.html

#tc101 #python #data_types