Course Content
Data Types in Python
Floating-Point Numbers
Here, we are going to talk about another crucial data type called float; it describes all numbers with a decimal point (both positive and negative): 1.5
, 56.9876
, and even 67.5e4
.
However, we don't need to worry about converting the number to a float representation using scientific notation. This is because Python has a format
method. Explanation:
This means 9.14 multiplied by 10 raised to the power of 7; but Python, by default, leaves space for six digits and replaces them with 0. By the way, we can specify this number. Here's another example where we leave just two numbers after the decimal point:
Section 1.
Chapter 4