Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
What does this program show? Then say how many numbers range(4, 10) makes.
range(a, b) makes b minus a numbers.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
i is 0, and 0 * 2 is 0.i is 1, and 1 * 2 is 2.i is 2, and 2 * 2 is 4.The program shows 0, 2 and 4.
range(4, 10) makes 10 - 4 = 6 numbers: 4, 5, 6, 7, 8 and 9.
Log in to join the discussion.
Loading…