How does a `for` loop hand you each value automatically, and why does `range(n)` stop one short of `n`?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
The running total total = 0 is given.
Use a for loop to add together every integer from 1 to 10, inclusive, leaving the sum in total. (Hint: range(start, stop) stops before stop, so you will need a stop value one past 10.)
for syntax and automatic assignment
Write the for variable in sequence: form, name the for and in keywords and the colon, then trace for n in range(5) printing n, listing each value assigned.
range(n) from 0 up to but not including n
State the half-open rule and write out every value range(5) produces together with the first and last values range(10) produces.
range(start, stop, step) and its defaults
Record that start defaults to 0 and step to 1, and list the values of range(3, 5), range(1, 4, 2) and range(4, 0, -1).