Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Python program to convert any base to decimal by using int() method
Next article icon

Given a number of int type, the task is to write a Python program to convert it to exponential.

Examples:

Input: 19Output: 1.900000e+01Input: 2002Output: 2.002000e+03Input: 110102Output: 1.101020e+05

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 thestr.format() method, and conversion refers to the conversion code of the data type.

Example:

Python3
# Python program to convert int to exponential# Declaring the integer numberint_number=110102# Converting the integer number to exponential numberexp_number="{:e}".format(int_number)# Printing the converted numberprint("Integer Number:",int_number)print("Exponent Number:",exp_number)

 
 

Output:


 

Integer Number: 110102Exponent Number: 1.101020e+05


 


Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp