course content

Course Content

Data Types in Python

Floating-Point NumbersFloating-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:

Present two numbers in scientific notation. Leave 4 digits after the decimal point for the first number, and 2 for the second. Do not put any spaces.

first_number = 238855
Present the first number in scientific notation
first_number_e = "{:

second_number = 67000000
Present the second number in scientific notation
second_number_e = "
print(first_number_e, second_number_e)
2.3886e+05, 6.70e+07

Section 1.

Chapter 4