Data Type in Python

Posted on

Introduction

Continuing on the discussion about Python programming language, this article will focus to the data type. Specifically, the data type exist or available in Python programming language. In python programming language, there are several types of data types. So, this article will discuss and describe those data types.

Data types actually defines on the type of content or data which is going to be processed. Either in a variable, constant or any other elements in python programming language. Depends on the data type, it will also decide the variable or constant type. Furthermore it will also decide the type of functions or methods which exist or available to process that variable or constant.

Data Type in Python

So, the data type in Python programming language exist in several types as follows :

  1. Boolean Data type

    This is the most simple data type. Because the value of this data type is only ranging between True or False. Also, for it can also represent a numeric or a number of 1 for stating the ‘True’ value and also a numeric or a number of 0 for stating the ‘False’ value. So, the possible value as examples for this data type are : True, False, 1, 0.

  2. String Data Type

    The next one is the string data type. It can be any character ranging from letters and numbers. But it need to be enclosed with the characters ” ” or ‘ ‘ in order to define a variable which is using a string data type. The examples for this data type are :  “Michael”, ‘Massachussets’.

  3. Integer Data Type

    Continue on the next data type, it is the integer data type. It is a number or a numeric. Specifically, it is a number or a numeric without having any fractions at all following it. For an example : 0, 1, -5.

  4. Float Data Type

    Another number or numeric data type. The main difference from integer data type is that the float data type is a numeric with additional fractions following after it. For an example : 1.5 , 2.75, 3.33.

  5. Hexadecimal Data Type

    This is another data type for representing number or numeric but in the base or the form of hexadecimal. For an example : 1d3, 9a.

  6. Complex Data Type

    It is a data type which is for expressing pairs of real and imaginary numbers. For an example : 1 + 5j.

  7. List

    List is a data type which is in the category of collection data type. It is a data type which consists of a collection of data. So, there are collection of several data where those data can have a different data type from one with another. The content or the collection of List can be changed either the value or the sequence. For an example : [True, ‘Germany’, “Berlin”, 340, 78.53]. For more details about list, just check an article with the title of ‘List in Python’ in this link.

  8. Tuple

    Another collection data type. It is a data type which is also consists of a collection of data. But the main difference from List is that although Tuple can consist of data that can have a different data type from one with another, it cannot be changed. For an example : (True, ‘Germany’, “Berlin”, 340, 78.53)

    For further information about tuple, just access the article in this link. Actually, that link will direct to an article with the title of ‘Tuple in Python’.

  9. Dictionary

    Dictionary is also another collection data type. Between List, Tuple and Dictionary, there is one main aspect differentiate it from the other. Dictionary is using a string key as an index to define data in dictionary.  For an example : {‘status’:True,’country’:’Germany’,’city’:’Berlin’,’id’:340,’price’:78.53}.

    In order to get more information on dictionary, just access the article with the title of ‘Dictionary in Python’ in this link.

  10. Set

    More on the collection data type in Python programming language is the one called ‘Set’. In case of set as a collection data type, it does not have any index like list or tuple. Furthermore, although the definition for set is also using the same one with dictionary which is a curly bracket, it does not have a key as a reference to the data. For an example : {1,2,3,4,5}

    An article showing more information and also detail description about set is available in another article with the title of ‘Set in Python’ in this link.

3 thoughts on “Data Type in Python

Leave a Reply