Data Types

We select a suitable data type based on the computation that we are performing. For example, to perform arithmetic operations where we used floating-point (real numbers for the performing area of the rectangle. Similarly, for processing character-based sequences (strings), it will be unrealistic to think operations such as multiplication of strings and division of strings. However, there are specific computations defined for each of these data types. For example, string reversal, finding a character in a string at a particular location, finding the number of characters in the string (length) etc. are valid operations on the strings. Below is a high level view of various data types we commonly use in Python.

The data stored in the memory can be of several types. This can be understood through an example. Suppose a person’s age is stored as a numeric value, whereas the address is stored as alphanumeric characters. Python consists of various standard data types that are used to define the operations possible while running a code.

Python has five standard data types −

  • Numbers

  • String

  • List

  • Tuple

  • Dictionary

Discussion on these standard data types will be studying in next chapter.