Skip to content

Python float variable | Declare and Use – floating-point

  • by

Python float variable declaration happens automatically when you assign a float value to a variable. The equal sign (=) is used to assign values to variables.

Must Read – Python Variables

Python float variable Example

You can declare a variable, operand to the left of the = operator is the name of the variable and the operand to the right of the = operator is the value stored in the variable.

See below example how to declaration float variable in python and print it.

marks = 100.0  # A floating point

Output: 100.0

Floating-point number user input

by using a float() function you can convert a number into a Floating-point number.

How to take user input from console in python?.

print("Enter a Number: ")
x = float(input())


Python float variable Declare

Q: How to know about data type?

Answer: Use type() function to get the type of the specified object. See the below example of how to get the object type data in python.

marks = 100.0  # A floating point


<class 'float'>

Do comment if you have any doubts and suggestions on this tutorial.

Note: This example (Project) is developed in PyCharm 2019.3 (Community Edition)
JRE: 1.8.0
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6
Python 3.7
All Python Programs are in Python 3, so it may change its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *