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:
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 |
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