0% found this document useful (0 votes)
26 views3 pages

Class 6 Float Complex Bool

The document discusses various Python data types including float, integer, complex, and boolean. It provides examples of how to represent values of each data type and notes on their usage and properties.

Uploaded by

kunala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

Class 6 Float Complex Bool

The document discusses various Python data types including float, integer, complex, and boolean. It provides examples of how to represent values of each data type and notes on their usage and properties.

Uploaded by

kunala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Float Data type:-

we can use float data type to represent decimal numner or floating point values.

ex:- a = 10.78
type(a)
class'float'

Note:- we can also represent floating point vlaues by using exponential


form(scienrific notation)

>>> 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.

Note:- raw_input function of python 2 is renamed as input() function in python3.

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.

Note:- raw_input function of python 2 is renamed as input() function in python3.

>>> g = 12.2e9
>>> print(g)
12200000000.0
>>>

The main advantage of exponential form is we can represent big values in less
memory.

Note:- we can represent int values in decimal(float),binary,octal and hexal


forms,but we can reprsent flaot value only by decimal form,we can not connvert
float by other forms.

we can do any mathmetical operation like


sumetion,substraction,multiplication,division etc in the intiger and float number.

Complex Data type:-

A complex number is of the form a+bj.

a + bj
a(real part) and b(imaginary part)

Note:- a and b contain intergers or floating point values.


ex:- 2+3j
10+7j
0.5+0.1j
9.87+8.78j

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)

But imaginary part should be specified only by using decimal form


ex:-
>>> b = 3+0b11j
SyntaxError: invalid syntax
>>>

Even we can perform opeartion on complex type values.

>>> 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
>>>

We can use complex type generally in scientific application and electrical


engineering application and telecome network frequence etc.

Boolean(bool) data type

We can use this data type to represent boolean values.


The only allowed values for this data type are : True and False.

Internally Python represents True as 1 and False as 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
>>>

>>> True + True


2
>>> True + False
1
>>> False + False
0
>>>

You might also like