Sunday 19 March 2017

Python programming part-3 Floats

Floats part-1 :

Floats are used in Python to represent numbers that aren't integers.
Some Example of numbers that are represented as floats are 0.5 and -7.8237591 .
They can be created directly by entering a number with a decimal point , or by using operations such as division on integers . Extra zeros at the number's end are ignored .

>>> 3/4
0.75
>>> 9.8765000
9.8765

Question :
Which of these will not be stored as a float ?
a. 7.0
b. 7
c. 2/4

_______________________________________________

Floats part-2 :

As you saw previously , dividing any two integers produces a float.
A float is also produced by running an operation on two floats , or on a float and an integer.

>>> 8 / 2
4.0
>>> 4+1.65
5.65

Question :
Fill in the blank with output of this code .
>>> 1+3+2+4.0+5

_________________________________________________
                                                                                                  


EmoticonEmoticon