Data Type In Python Part-3
For freshers and Professionals |
Complex Data type:
a+bj
a= real part
b=Imaginary Part
x=10+20j
type(x) == > <class,Complex>
2. x=10.5+2.3i == ==> this is invalid syntax Imaginary part should be j
3. x=0b1111 + 20j ==== >valid
4. x=15+0b1111 ======> Invalid , Imaginary part comparably should be decimal, here we
3. bool datatype :
It allows two values True or False
x=True
x=False
x=True+True ================> 2
x=True+False=================> 1
x=False-False=================> 0
x=False-True==================> -1
4. str datatype :
To store String we can use str datatype in Python . In Python both single quotes and double
quotes treated as String
Example : x='Raju' and x= "Raju" both are valid
Example : x=raju ====> invalid , string should be in single or double quotes.
Example : Multi line String
"hello
Raju"
Above syntax is invalid because single quotes or double quotes only for single line string
Note : If you want to store multiline string then use triple quotes """
Example : """ hello
Raju"""
Example : Double quotes inside Triple Quotes:
""" java is a "platform" independent language """
output = java is a "platform" independent language.
To be continued str in Python data type part-4
Comments
Post a Comment