Python supports a vast variety of data structures, but it's primitive data types which do not require any library invoking are as follows:
Numeric data type which enables a programmer to store data on which s/he requires to perform mathematical operations like addition, subtraction, multiplication, division, etc. Python provides three data types to store these numeric data.
Mathematically whole number are Integers. e.g., age, number of vehicles, goods sold, parts of a car, etc. are always a whole number. To define an integer variable in Python, you need to assign an integer to the variable.
age=28 goodsSold=123 partsReplaced=22 totalUnits_manufectured=125478
The mathematical definition of Floating numbers is a number which is in the fraction of the whole number. e.g., the tax charged on a watch, the value of pi or gravitation constant g, etc. To define float variables assign a fractional value to it. e.g.
pi=3.14 g=9.8 taxCharged=1254.32
A unique type of data which I guess is present only in Python is the complex number. A complex number is in the form of x+i(iota)y. In Python, this iota is represented with letter 'j". I can not imagine any real-world example of this type of data. To define this kind of data consider the following examples:
There will be chances in which you need to store true or false values while writing code for solving a complex business problem. To handle these true and false values Python provides the boolean type of data type. e.g., a car is under warranty, bill paid, raining outside, etc. To define a boolean variable use True or False value to assign to it. e.g.
billPaid_mobile=True billPaid_electricity=False rainingOutside=False
Concerning programming, A string is a sequence of alphanumeric characters which may have a meaning to the problem statement a programmer is solving. e.g.
carModel="Aventador Roadster" carManufecturer="Lamborghini"
Let us consider the following scenario and think on variables and their types we should have in our program if we need to design its programming solution.
A car repair workshop wants to automate their system. What all the things you will consider to store the data they need for processing a car from the point it enters their workshop.
Apart from these basic data types, Python supports a few complex data types as primitive data types which are List, Tuple and Data Dictionary.
List: is a mutable collection of different values of data, in this data is numerically indexed by default and the index starts with 0 (zero).
Tuple: is like list but it is immutable.
Dictionary: is a collection of data in form key-value pair. If you are familiar with JSON, you may relate data dictionary with that.
We are going to have a detailed discussion of these data types in subsequent articles.