ScanSkill

float data type

float data type represents the floating point numbers. It represents real numbers and is written with a decimal point dividing the integer and fractional parts. E.g. 13.13, -7.13, 7.13+e5, etc.

Constructors

  • float(): It converts an expression into a floating point number.
  • literal syntax: It is used to initialize a new instance of the float type. e.g.
>>> 1.0
1.0
>>> 3.14
3.14
>>> 3.0/2
1.5
>>> 2.0 + 1.5
3.5

Examples

>>> f=1.2
>>> f
1.2

Also, floats that are separated by the underscore _ are also valid:

>>> float1 = 13_14.14_13
>>> float1
1314.1413

Floats beyond maximum size are referred to as inf, infinity, or INFINITY.

>>> float1 = 2e500
>>> float1
inf