MASTERY 09 BASIC TYPES AND THEIR USES IN PYTHON 3
Types are a category for things within Python with which Python will work. Types are:
- integers
- Whole numbers from negative infinity to infinity, such as 1, 0, -5, etc.
- float
- Short for "floating point number," any rational number, usually used with decimals such as 2.8 or 3.14159.
- strings
- A set of letters, numbers, or other characters.
- tuples
- A list with a fixed number of elements. ie x=(1,2,3) parentheses makes it a tuple.
- lists
- A list without a fixed number of elements. ie x=[1,2,3] note the square brackets, a list
- dictionaries
- A type with multiple elements i.e. x = {1: 'a','b': 2,3: 3} where you address the elements with, e.g., a text..
- teaken from: http://en.wikiversity.org/wiki/Python/Basic_data_types
- To obtain a "type" you can use the variable inside a type() and it will return you the type of variable that are you using.
- example:
- a=58
- print(type(a))
- and the program will show you that this variable is of int's type
No hay comentarios:
Publicar un comentario