Vipin | Sun, 07 Jun, 2020 | 188
In Python Data types can be broadly categorized into five different types, listed as follows:
There are generally four numeric data types in Python. They areintegers, long integers, floating point numbers, and complex numbers.
a = 10 b = 30 c = 40
Numbers with certain places after the decimal point are referred to as floating point numbers in the programming language:
a = 20.45 b = 45.099 c = 767.88788
A complex number has both real and imaginary parts, and Python allows you to specify this data type in a very easy and convenient way.
<variable_name> = complex(x,y)
Here, x is the real part and y is the imaginary part. Here, j plays the role of iota.
num = complex(3,5) # or num = 3+5j
A Boolean data type generally has only two values 'True' or 'False'.
Boolean data type is a sub type of integers.
<variable_name> = <'True' or 'False'>
a = True b = False
Boolean data types can be referred to as an on and off switch, which has only two values to chose from.
A Python string is a contiguous sequence of Unicode characters.
Single quotes or double quotes can be used to denote a string. For multiline string representation, ''' or "' can be used.
<variable_name> = <String Sequence>
my_str1 = "HelloWorld" my_str2 = 'Selfcode.in' my_str3 = ''' This is multiline String '''