Presentation is loading. Please wait.

Presentation is loading. Please wait.

For Loops Pages 92 - 93.

Similar presentations


Presentation on theme: "For Loops Pages 92 - 93."— Presentation transcript:

1 For Loops Pages

2 Anatomy Of A ‘For Loop’ Iterates through a sequence
Needs a counter variable is assigned a number Counter variable changes by the same amount on each iteration of the loop The range() function allows you to count in all kinds of ways It is traditional to use “i” or “j” as counters in a for loop, even though most of the time you should use a more descriptive variable name

3 print(“Output:”) for i in range(5) : print(i) Output: 1 2 3 4 print(“Output:”) for i in range(2, 6) : print(i) Output: 2 3 4 5 print(“Output:”) for i in range(0, 25, 5) print(i) Output: 5 15 20 print(“Output:”) for i in range(5, 0, -1) : print(i) Output: 5 4 3 2 1


Download ppt "For Loops Pages 92 - 93."

Similar presentations


Ads by Google