The data which is stored in memory are of different types. In python there are five types of data types are used –
These are the whole numbers and the range of integers are depend on the hardware on which python is run. Integers are of different types like positive, negative, zero, and long.
I = 123 // Positive Integer
J = -20 // Negative Integer
K = 0 // Zero Integer
Long integer is used to store the large numbers without losing precision. To write long integers L suffix is used.
I = 99999999999L
It also includes octal and hexadecimal number. To represent the octal which have base 8 in python add a preceding zero. So the interpreter recognized that you wanted the value to be in base eight and not in base ten.
I = 11 Then in Octal you will write –
>>I = 011 >>print I
Then it will give the output 9
To represent the hexadecimal number which have base 16 in python add a preceding 0x. So the interpreter recognized that you wanted the value to be in base sixteen and not in base ten.
>>> I = 0x11 >>> print I
Then it will give the output 17
They symbolize the real numbers that are written with a decimal point dividing the integer and fractional parts. It includes the decimal value which is not included in integers. Floating point numbers may also be in scientific notation with E or e indicating the power of 10 like 5.5e4 i.e. 5.5 * 10^2
I = 2.5
J = 7.5E4 etc.
Complex numbers are of the form of a + bj where a is realpart floating value and b is the imaginary part floating value and j represents the square root of -1.
2.5 + 24
This blog will help you get a better understanding of Automate Your Coding with Python!Previous Next
Learn SQL in 16 hrs from experts