+ 1

How to use float?

6th Nov 2022, 2:06 AM
Jeorge Rey Antipaso
Jeorge Rey Antipaso - avatar
6 Answers
+ 2
Hej, Jeorge Rey Antipaso ! Floats are representing floating point numbers in Python. You are using them as ordinary numbers, when ever you need to represent numbers as a fractions of integers, like the result of two divided numbers. You can use the function float() to convert from other data types to floats, like from strings or from integers. What can be confusing when using floats is that the decimal numbers representing on the screen only are aproximations of the hardware base 2 fractions the computer handle, which in turn, you have to learn to handle. Read more at for examples: https://docs.python.org/3/tutorial/floatingpoint.html
6th Nov 2022, 3:14 AM
Per Bratthammar
Per Bratthammar - avatar
+ 1
Thanks 😊
6th Nov 2022, 2:35 AM
Jeorge Rey Antipaso
Jeorge Rey Antipaso - avatar
+ 1
In Python “x = float()” but remember that divisions always evaluate to floating point number/s.
7th Nov 2022, 4:09 AM
Hunter
Hunter - avatar