Floating point number is real numbers with decimal point (.)or fractional part. It can be positive or negative.

Example:

5678.90

-2.88

-2.88

0.99

>>> z = -1.234>>> type(z)<class ‘float’>

Let’s do arithmetic:

>>> x = 8+8.1>>> print (x)16.1>>> print (type(x))<class ‘float’>

Some key notes:

1. numbers separated with underscore can consider a valid float as long has decimal point

>>> x = 66_77_88.3_21>>> type (x)<class ‘float’>

2. real numbersĀ with a fractional part represented by scientific notation e or E, or those floating numbers that exceeded the maximum size (1.8 * 10^308), it will be referred as “infinity” or “inf”

>>> 1.8e308inf>>> x = 1.8e308>>> print (x)inf>>> type (x)<class ‘float’>

>>> 0.4e9400000000.0>>> x = 0.4e9>>> type (x)<class ‘float’>

3. there’s a function float() to convert string into float class.

>>> x = 100>>> float (x)100.0