For those of you who know c and c++, this will be a repeatation.
For the others, you will learn the different data types one can use in Python.
In our previous blog, we solved a few mathematical equations with numbers.
Every number will be of a certain Data Type.
To know a few,
1. INT data type
2. FLOAT data type
3. BOOL data type.
The INT data type is the integer data type.
It consists of whole numbers. That is numbers without a fractional part.
For eg: 2,3,4,5 are all INT type.
The FLOAT data type consists of numbers with fractional part.
For eg: 2.7,2.1,3.7.
The BOOL data type is used to check is the expression written in the paranthesis results in a true or a false value.
bool(<expression to be checked>)
For eg: bool(2<3) will return a TRUE value.
bool(2!=2) will return a FALSE value.
These can be used when some part of code must be executed only at certain conditions.
To check what data type a number belongs to, one can use the 'type' command in Python.
type(2) gives 'int' as the result.
type(3.7) gives float as the result.
The bool data type can be made use of in the following way:
NOTE: bool commands returns only TRUE or FALSE as the output.
These are the general Data Types in Python.
You will learn more Data Types in the following Blogs!
Stay Tuned!
For the others, you will learn the different data types one can use in Python.
In our previous blog, we solved a few mathematical equations with numbers.
Every number will be of a certain Data Type.
To know a few,
1. INT data type
2. FLOAT data type
3. BOOL data type.
The INT data type is the integer data type.
It consists of whole numbers. That is numbers without a fractional part.
For eg: 2,3,4,5 are all INT type.
The FLOAT data type consists of numbers with fractional part.
For eg: 2.7,2.1,3.7.
The BOOL data type is used to check is the expression written in the paranthesis results in a true or a false value.
bool(<expression to be checked>)
For eg: bool(2<3) will return a TRUE value.
bool(2!=2) will return a FALSE value.
These can be used when some part of code must be executed only at certain conditions.
To check what data type a number belongs to, one can use the 'type' command in Python.
type(2) gives 'int' as the result.
type(3.7) gives float as the result.
The bool data type can be made use of in the following way:
NOTE: bool commands returns only TRUE or FALSE as the output.
These are the general Data Types in Python.
You will learn more Data Types in the following Blogs!
Stay Tuned!
No comments:
Post a Comment