Class 6 Float Complex Bool
Class 6 Float Complex Bool
we can use float data type to represent decimal numner or floating point values.
ex:- a = 10.78
type(a)
class'float'
>>> f = 1.2e3
>>> print(f)
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
10--->int
'scodeen'--->str
10.5--->float
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
>>> g = 12.2e9
>>> print(g)
12200000000.0
>>>
The main advantage of exponential form is we can represent big values in less
memory.
a + bj
a(real part) and b(imaginary part)
In the real part if we use int values then we can specify that either by
decimal,octal.binary or hexa decimal form.(onlt int)
ex:-
>>> a = 0b11+5j
>>> a
(3+5j)
>>> a = 10 + 1.5j
>>> b = 20 + 2.5j
>>> c = a+b
>>> c
(30+4j)
>>> type(c)
<class 'complex'>
>>> d = a-b
>>> d
(-10-1j)
>>>
Note:- complex data type has some inbuilt attributes to retrive the real part and
imaginary part.
>>> a = 10 +7j
>>>
>>> a.real
10.0
>>> a.imag
7.0
>>>
>>> a = True
>>> type(a)
<class 'bool'>
>>> b = False
>>> type(b)
<class 'bool'
ex:-
>>> a = 10
>>> b = 20
>>> c = a<b
>>> print(c)
True
>>> d = a>b
>>> print(d)
False
>>>