2

I am trying to use 1e6 to return 1000000, but I need to set the '6' to a variable. But

units = int(6) 1e(units) 

gives me a syntax error. The python reference docs have no details on how to use variables instead of ints to achieve this.

2 Answers 2

6

The e notation is just short for 10 raised to a power, so you can do something similar

>>> units = 6 >>> 10 ** units 1000000 

Or more generally

def e(base, exp): return base * 10 ** exp >>> e(1, 6) # 1e6 1000000 >>> e(2.5, 6) # 2.5e6 2500000.0 
Sign up to request clarification or add additional context in comments.

Comments

2

You can do as CoryKramer suggested, heres other way below:

>>> units = 6 >>> float(f'1e{units}') 1000000.0 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.