Python Data Types

In this section we will cover some of the key data types used in python. Data types are the basic building blocks when constructing large pieces of code. Data types basically represents the type of data a variable can store/hold.

Some of the key data types used in python are listed below:
Type Name Description
Integer int Whole numbers such as : 1,2,400...
Floating Point float Numbers with decimal point such as 2.3,4.6...
String str Ordered sequence of Characters: 'sammy', "Hello" , "2000" ,"400" ...
List list Ordered sequence of objects : [10,"w",3.4]
Dictionaries dict Unordered Key:Value pairs: { "key" : "value" , "name" : "sam"}
Tuples tup Ordered immutable sequence of objects : ( 10 , "hello" , 200.3)
Sets set Unordered collection of unique objects : {"a","b"}
Boolean bool Logical operator representing True or False
Please note that lists,dictionaries,tuples and sets aren't really data types , rather they are data structures. A data structure is a particular way of organizing data in a computer so that it can be used effectively. A data structure can contain objects of various data types. These can be called non-traditional data types.
Type in the above table represents the keyword Python uses to recognise a specific data type.

The type() function in python returns the data type of the object enclosed within the parenthesis. In the code below , we will use this type() function to identify the data types of the objects.
print(type("Animal"))
print(type(1))
print(type(3.14))
output :
<class 'str'>
<class 'int'>
<class 'float'>




Popular Tutorials

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.