Python Programming - DataType

Posted by Aditya Nema
Hello All, In the last article we discuss the python introduction. Today we will be going to discuss the datatype used in python. The datatype is one of the most important concept in programming. Let us discuss that :

Datatype in any programming language is mostly of two types one is the built-in data type and the other is user-defined datatype. 

The user-defined data type includes class and all we will discuss this in more detail in upcoming articles.

The following is the built-in data types used in python :

  • Text type:            str
  • Numeric Type:    int, float, complex
  • Sequence Type:  list, tuple, range
  • Mapping Type:   dict
  • Set Type:            set, frozenset
  • Binary Type:    Byte, Bytesarray, memoryview

We will discuss all these data types in our upcoming articles.

As already discussed there s a built-in function known as the type() which is used to identify the type of data store in the variable. In very simple words datatype is nothing but the type of data variable holds. There can be any type of data as a string of characters, integer, decimal, etc.

All these words like list, dict, etc are reserved words known as keywords. This set of words is reserved and you cannot use them as the name of variable, function, class, etc.

Let us move towards our first program known as a simple hello program. In python command line just type as per the image below


The print is the built-in function used to print the values. Whatever you write between the double quotes will be printed on the screen.

The below code will illustrate how to define the variable and do the basic addition operation in python.

>>> # defining the variables 
>>> a = 7
>>> b = 8
>>> # sum the variable and store it in another variable
>>> c = a+b
>>> #display the result
>>> print(c)

In the next article, we will discuss different types of operators.


back to top