Data Types is one of the basic concepts you will ever learn in any Programming Language. But What are the Data Types?
Data Types are those values which tell a Program to what operation to perform on a Particular Data.
The Data Types can vary from Language to Language It Depends on a Programming Language which types of Data Types it Supports.
Talking about Particularly Python It supports 5 Different Data Types:- *Numeric *Sequence *Boolean *Set *Dictionary
In Numeric Data Type in Python contains int, double, float and complex numbers in a single data type called Numeric.
This value is represented by int class. It contains positive or negative whole numbers (without fraction or decimal). In Python, there is no limit to how long an integer value can be.
This value is represented by float class. It is a real number with floating-point representation. It is specified by a decimal point. Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation.
A complex number is represented by a complex class. It is specified as (real part) + (imaginary part)j. For example – 2+3j
In Python, the sequence is the ordered collection of similar or different data types. Sequences allow storing multiple values in an organized and efficient fashion. There are several sequence types in Python –
*String *List *Tuple
In Python, Strings are arrays of bytes representing Unicode characters. A string is a collection of one or more characters put in a single quote, double-quote or triple quote. In python there is no character data type, a character is a string of length one. It is represented by an str class.
Lists are just like the arrays, declared in other languages which is an ordered collection of data. It is very flexible as the items in a list do not need to be of the same type.
Just like list, a tuple is also an ordered collection of Python objects. The only difference between type and list is that tuples are immutable i.e. tuples cannot be modified after it is created. It is represented by tuple class.
Data type with one of the two built-in values, True or False. Boolean objects that are equal to True are truthy (true), and those equal to False are falsy (false). But non-Boolean objects can be evaluated in Boolean context as well and determined to be true or false. It is denoted by the class bool.
In Python, Set is an unordered collection of data type that is iterable, mutable and has no duplicate elements. The order of elements in a set is undefined though it may consist of various elements.
Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds the key: value pair. Key-value is provided in the dictionary to make it more optimized. Each key-value pair in a Dictionary is separated by a colon: whereas each key is separated by a ‘comma’.
As we do now have a basic understanding of Data Types Now we will move on to Concepts like Variables and Operators.
Stay Tuned for More post like this.
I will like you to subscribe to my E-mail List for Weekly Updates