DATA TYPES In PYTHON
data type part-1
>. Data types
>. Coding
Data types
Before going ahead with what is data type and why do we need it? We should first know how a data is stored in a system.
In every electronic system we have RAM which stores the data temporarily. All the data that we enter is in high level but it is always stored in low level inside the system so that the system/machine can understand.
So RAM consists of several bytes, each byte consists of 8 bits, each bit has two transistors which can store high and low value (1’s and 0’s).
Now we know that RAM can only take inputs in 0’s and 1’s. Apparently the data in real world is not combination of 0’s and 1’s. We have basic 4 types of real world data which are integers, real numbers, characters, yes/no types of data.
The basic data types in python which represents integers, real world, characters, yes/no type data are int, float, str, bool respectively.
Examples:
Integers — Age of a person, Number of people, House number, Population of a country, number of galaxies or planets all represent whole numbers. Whole numbers belong to integer type data.
Real world data — Height & weight of a person, GDP of country, your CGPA/SGPA, Literacy rate are all examples of real world data where it may or may not be a whole number. These real world data belong to float data type
Character — We are surrounded by several things while have names, there isn’t a single thing in the world that don’t have a name for it. And for communication words play major role. All these are characters which belong to string data type.
Yes/no — We ask several yes or no, true or false questions to one another like married or not? Graduated or not? Employed or not? Literate or not? All these belong to boolean data type
Coding — data types
1) Integer data type — int
2) Real world data type — float
3) Character data type — str
In python language we don’t have separate data type for character and string. Here string data type is inclusive of single character type data, collection of characters, and also multi line strings. Which in depth we shall study while learning about strings.
4) Complex numbers —
We have seen the real numbers and integers but there are also imaginary numbers in this world. These imaginary numbers belong to complex numbers. If you want to know where these imaginary numbers are used in real world then here are few examples, in mathematics I’m sure everyone is aware of quadratic equations and certainly in schooling days we have come across using complex numbers there.
5) Boolean —
Boolean type of data will have two states true/false. Based on the condition that we want to check, the return value of expression changes. In python Boolean type of data belongs to bool.
Quiz For YOU:
Thanks for Reading :)