Presentation is loading. Please wait.

Presentation is loading. Please wait.

Gavin Restifo March 1, 2019 Today: Repetition Part 2 - For Loops

Similar presentations


Presentation on theme: "Gavin Restifo March 1, 2019 Today: Repetition Part 2 - For Loops"— Presentation transcript:

1 Gavin Restifo March 1, 2019 Today: Repetition Part 2 - For Loops
CS 1110 Gavin Restifo March 1, 2019 Today: Repetition Part 2 - For Loops

2

3 Last time While loops Strategies for repetitive code Needs 3 things
Condition Something to be repeated Adjust the condition Strategies for repetitive code Top down Start with the loop Bottom up Start with everything else and repeat

4 Today: For loops Similar to while
Does not require a condition Instead requires a collection Almost everything you can do with while you can do with for What might you not be able to do with for? Keywords: for in

5 Syntax for something in collection: # Repeat this code For Something
Iterate through whatever you give it Something Assigned in the loop In Specifies the set of iteration Collection Whatever we want to loop through

6 Collections (so far) Strings Ranges Lists Tuples*


Download ppt "Gavin Restifo March 1, 2019 Today: Repetition Part 2 - For Loops"

Similar presentations


Ads by Google