0

我是 Python 的初学者,我遇到了一些麻烦。我必须for解决这个问题。谁能解释一下我会怎么做?

nextNValues (startValue, increment, numberOfValues)

此函数创建一串值numberOfValues,从增量开始startValue并按增量计数。例如,nextNValues (5, 4, 3)将生成一个字符串(不包括注释):

5 - 起始值
9 - 按 4 计数,增量
13 - 在 3 行输出后停止,numberOfValues

4

3 回答 3

3

你可以使用range(startValue,startValue+(increment*numberofValues),increment).

于 2013-10-06T05:14:45.833 回答
2
for i in range(numberOfValues):
    print startValue + i * increment

I am not sure if that is exactly what you are looking for... but it is my suggestion based on the information you have posted.

于 2013-10-06T05:10:14.847 回答
0

It would probably be easiest to write a for loop with an index like i and use that to add i*increment ti start value and save the resulting value to a list. Have the loop run numberOfValues times. If this is homework it would be better for you to write out the actual code for yourself

于 2013-10-06T05:09:07.513 回答