#mastery09 Mastery 09 #Tc1014

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
#mastery09 Mastery 09   #Tc1014

CC BY 4.0 #mastery09 Mastery 09 #Tc1014 by Eutimio Machuca is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.