--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.
So let’s see which ones are the basic types in python:
types.
NoneType
- The type of
None
.
types.
IntType
- The type of integers (e.g.
1
); alias of the built-inint
.
types.
LongType
- The type of long integers (e.g.
1L
); alias of the built-inlong
.
types.
FloatType
- The type of floating point numbers (e.g.
1.0
); alias of the built-infloat
.
types.
StringType
- The type of character strings (e.g.
'Spam'
); alias of the built-instr
.
types.
TupleType
- The type of tuples (e.g.
(1, 2, 3, 'Spam')
); alias of the built-intuple
.
types.
ListType
- The type of lists (e.g.
[0, 1, 2, 3]
); alias of the built-inlist
.
types.
DictType
- The type of dictionaries (e.g.
{'Bacon': 1, 'Ham': 0}
); alias of the built-indict
.
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