Q. Using value 12, create data (that contains 12 in it) of following types. Give at least two examples for each type of data. Check type of each of your example using type () function, e.g., to check the type of 3.0, you can type on Python prompt: type (3.0).
(Hint: 3 is integer but 3.0 is floating point number.)
(a) | Integer | |
(b) | Floating point number | |
(c) | Complex number |
Answer :-
(a) Integer :-
>>> a = 12
>>> b = 5
>>> type(a)
<class 'int'>
>>>type(b)
<class 'int'>
(b) Floating point number :-
>>> a = 12.5
>>> b = 99.88
>>> type(a)
<class 'float'>
>>> type(b)
<class 'float'>
(c) Complex number :-
>>> a = 12.5 + 5j
>>> b = 99.00 + 657j
>>> type(a)
<class 'complex'>
>>> type(b)
<class 'complex'>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )