Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6865589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:04:22+00:00 2026-05-27T03:04:22+00:00

Consider the following Python snippet: for ix in [0.02, 0.2, 2, 20, 200, 2000]:

  • 0

Consider the following Python snippet:

for ix in [0.02, 0.2, 2, 20, 200, 2000]:
    iss = str(ix) + "e9"
    isf = float(iss)
    print(iss + "\t=> " + ("%04.03e" % isf) + " (" + str(isf) + ")")

It generates the following output:

0.02e9  => 2.000e+07 (20000000.0)
0.2e9   => 2.000e+08 (200000000.0)
2e9     => 2.000e+09 (2000000000.0)
20e9    => 2.000e+10 (20000000000.0)
200e9   => 2.000e+11 (2e+11)
2000e9  => 2.000e+12 (2e+12)

Is it possible to "go back" somehow? That is:

2.000e+07 => 0.02e9 
2.000e+08 => 0.2e9
2.000e+09 => 2e9    
2.000e+10 => 20e9   
2.000e+11 => 200e9  
2.000e+12 => 2000e9

… I’d specify I want the exponent to be e+09; and then whatever number I throw at this hypothetic function, returns the number value in that exponent? Would it be possible to specify zero padding for both the whole and the decimal part in each case? (i.e. 000.0200e9 and 020.0000e9)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:04:23+00:00Added an answer on May 27, 2026 at 3:04 am

    Format it yourself (see Format Specification Mini-Language):

    for ix in [.02e9, .2e9, 2e9, 20e9, 200e9, 2000e9]:
        print('{:.3e} => {:0=8.3f}e9'.format(ix, ix / 1e9))
    

    Output

    2.000e+07 => 0000.020e9
    2.000e+08 => 0000.200e9
    2.000e+09 => 0002.000e9
    2.000e+10 => 0020.000e9
    2.000e+11 => 0200.000e9
    2.000e+12 => 2000.000e9
    

    Explanation

    {:0=8.3f} means "zero-pad, pad between the sign and the number, total field width 8, 3 places after the decimal, fixed point format".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following example code class A: def __init__(self, i): self.i = i print("Initializing
Consider the following Python code: import os print os.getcwd() I use os.getcwd() to get
Consider the following snippet of Python code: from sqlalchemy import * from sqlalchemy.orm import
consider the following python code: import gtk class MainWindow(): def __init__(self): self.window = gtk.Window()
Consider the following birthdays (as dob ): 1-Jun-68 1-Jun-69 When parsed with Python’s datetime.strptime(dob,
Consider the following Python exception: [...] f.extractall() File C:\Python26\lib\zipfile.py, line 935, in extractall self.extract(zipinfo,
Consider the following Python (3.x) code: class Foo(object): def bar(self): pass foo = Foo()
consider the following python code class Base(object): def __init__(self): self.foo = 5 class Derived(Base):
Consider the following Python code: 30 url = http://www.google.com/search?hl=en&safe=off&q=Monkey 31 url_object = urllib.request.urlopen(url); 32
Let's consider the following table models for sqlalchemy in python. class Worker(Base): id Column(Integer,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.