For loop in python to increment the logarithmic scale

I want to know if it is possible to iterate over a variable in increments on a scale. In particular, I want to generate values ​​for q from 1E-10 to 1E-2 in increments of the scale scales 1E-10, 1E-9, 1E-8, 1E-7,1E-6,1E-5,1E-4, 1E-3,1E-2. Can you suggest how I can write a for loop for this?

+4
source share
1 answer

a simple understanding of the list and range( -1- the upper bound is not reached):

>>> [10**i for i in range(-10,-1)]
[1e-10, 1e-09, 1e-08, 1e-07, 1e-06, 1e-05, 0.0001, 0.001, 0.01]

for a lazy assessment, just replace []with ()to instead create an understanding of the generator:

(10**i for i in range(-10,-1))
+4
source

Source: https://habr.com/ru/post/1693207/


All Articles