Google News
logo
Python Program to Create floating point numbers
In the following example of Python program that demonstrates how to create floating-point numbers :
Program :
# Creating floating-point numbers
num1 = 3.14
num2 = -2.5
num3 = 0.0

# Outputting the floating-point numbers
print(num1)
print(num2)
print(num3)


In this program, we create three floating-point numbers named `num1`, `num2`, and `num3` and assign them the values `3.14`, `-2.5`, and `0.0`, respectively. Floating-point numbers are a type of numeric data in Python that represent real numbers, both positive and negative, as well as zero.

We then use the `print` function to output the values of the floating-point numbers to the console. When we run the program, it will output the following:

Output :
3.14
-2.5
0.0
You can perform various arithmetic operations on floating-point numbers in Python, such as addition, subtraction, multiplication, and division.

However, due to the way that floating-point numbers are stored in memory, you may encounter issues with precision or rounding errors in certain situations.