A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python-program-to-convert-float-to-exponential/ below:

Python program to convert float to exponential

Python program to convert float to exponential

Last Updated : 26 Oct, 2021

Given a float number, the task is to write a Python program to convert float to exponential.

Examples:

Input: 19.0
Output: 1.900000e+01

Input: 200.2
Output: 2.002000e+02

Input: 1101.02
Output: 1.101020e+03

Approach:

Syntax:

String {field_name:conversion} Example.format(value)

Errors and Exceptions:

ValueError: Error occurs during type conversion in this method.

More parameters can be included within the curly braces of our syntax. Use the format code syntax {field_name: conversion}, where field_name specifies the index number of the argument to the str.format() method, and conversion refers to the conversion code of the data type.

Example:

Python3
# Python program to convert float to exponential

# Declaring the float number
float_number = 1101.02

# Converting the float number to exponential number
exp_number = "{:e}".format(float_number)

# Printing the converted number
print("Float Number:",float_number)
print("Exponent Number:",exp_number)

Output:

Float Number: 1101.02
Exponent Number: 1.101020e+03


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4