Python Data Types - float

Number with decimal point which is obviously not a whole number come under float data type.

e.g.,

Rates of petrol, diesel are generally shown in decimal points. 

petrol = 110.34

diesel = 94.52

let’s check type() to confirm types of above prices,


Another use of float data type is to store long number. long numbers can be stored using exponential notations.

e.g.,

a=854600000000000000000000000000000

reading above number is quite difficult to read at first seen.

If we learn understand exponential notations it is to read long numbers

We can write above number in exponential like

a=8.546e+32 or 8.546e32

as there are 32 digits after decimal point e+32 is written.

As we know we can declare long integer number using int data type. But reading or remembering them is not so easy. We can save them in shorter format like exponential notations. Like below shown we can convert long int numbers into exponential format.

Here, we have converted integer number into exponential format but the output is in the string data type.

Here now we got the number in float data type.

Python scientific i.e., exponential notation does reading and understanding the numbers very easily.

Comments

Popular posts from this blog

Python Data Types - Complex

Python Data Types - int