Account
Categories

Float List


Definition:

If you are required to store the data of floats in the form of a list, then you can create a float list.

Now you will clearly understand this with the help of the diagram.

a = [6.2, 12.5, 13.8]

        ┌─────────┬─────────┬─────────┐
Index → │   012     │
        ├─────────┼─────────┼─────────┤
Value → │ 6.212.513.8    │
        └─────────┴─────────┴─────────┘

Syntax:

list_name = [float1, float2, float3]

Example:

a = [6.2, 12.5, 13.8]
print(a)

Output:

Exercise

Create a float list with values 1.5, 2.5, 3.5 and print it using Python.