Python program to convert exponential to float

Given a number in exponential format, the task is to write a Python program to convert the number from exponential format to float. The exponential number is a way of representing a number.

Examples:

Input: 1.900000e+01
Output: 19.0
Input: 2.002000e+03
Output: 2002.0
Input: 1.101020e+05
Output: 110102.0

Approach:

  • First, we will declare an exponential number and save it in a variable.
  • Then we will use the float() function to convert it to float datatype.
  • Then we will print the converted number.

Syntax:

float(x)

The float() method is used to return a floating-point number from a number or a string.

Example:

  • Python3

# Python program to convert exponential to float

# Declaring the exponential number

exp_number = "{:e}".format(110102)

# Converting it to float data type

float_number = float(exp_number)

# Printing the converted number

print("Exponent Number:",exp_number)

print("Float Number:",float_number)

Output:

Exponent Number: 1.101020e+05
Float Number: 110102.0

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store