Range FunctionΒΆ
-
Replace
<1>in the following code with a call torange()so that the for loop prints out all integers from 1 to 10, inclusive.Therangefunction takes 1, 2, or 3 integer parameters. The parameters arerange(start=0, stop, step=1). If astartvalue is not provided, the value0is used. If astepvalue is not provided, the value1is used. Thestopvalue indicates the upper limit that the result should be less than. E.g., ifstopis10, then the result of therangecall will end at9.
-
Replace
<1>in the following code with a call torange()so that the for loop prints out all integers from 0 to 99, inclusive.Remember that you can omit the first parameter if you want the result to start at 0.
-
Replace
<1>in the following code with a call torange()so that the for loop prints out all integers from -10 to 10, inclusive.Parameters can be negative, and ifstepis one, the results will increase by 1 each time through the loop.
-
Replace
<1>in the following code with a call torange()so that the for loop prints out all even integers from 0 to 100, inclusive.Parameters can be negative, and ifstepis 1, the results will increase by 1 each time through the loop.
-
Replace
<1>in the following code with a call torange()so that the for loop prints out all multiples of 5 from 0 to 200, inclusive.Go back and review previous questions if you need a hint.
-
Replace
<1>in the following code with a call torange()so that the for loop prints out all integers from 10 down to 1, inclusive.Provide a step of
-1.range()produces values down to but not equal to or less than thestopvalue, if the step is negative.