Answer the question
In order to leave comments, you need to log in
How to solve the problem with the calculation of coefficients?
How to write code correctly so that the program would count from 1 to 6000, one coefficient for each unit, let's say 1 = 0.4. And from 6000 to 10000 it is these 4000 thousand according to another coefficient, let's say 1 = 0.6?
Answer the question
In order to leave comments, you need to log in
def some_calc_func(param):
coef = 0.4
if 6000 < param < 10000:
coef = 0.6
# здесь код вычислений, возвращается результат перемножения, к примеру
return coef * param
for i in range(1, 10001):
print(some_calc_func(i))
COEF = 0.4
INC_COEF = 0.6
INC_COEF_FACTOR = 6000
def calc_result(value):
if value > INC_COEF_FACTOR:
return (value - INC_COEF_FACTOR) * INC_COEF + INC_COEF_FACTOR * COEF
return value * COEF
2 rounds one after the other
for i in range(1, 6000):
coefficient = 0.4
for i in range(6000, 10001):
coefficient = 0.6
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question