Ask coding questions

← Back to all posts
What are floats in python?
YvngBashit (17)

What are floats in python?

Geocube101 (625)

Floats are basically decimals
integer = 5
float = 5.0


Floats are basically decimals. like this:

a int is = 1
a float is = 1.0

to turn to a float, it's like this:

d = 10
s = d.float()

That should work

ADoctor (4)

Floats work similarly to decimals. Integers cannot have any decimal places, whereas floats are always displayed with at least one (if there are none specified, a '.0' will be added at the end).