Presentation on theme: "Using Lists and Loops in Lots of Circles Week 4. Lists For example: to do list, shopping list In CS: An ordered set of values One name, multiple values,"— Presentation transcript:
Lists For example: to do list, shopping list In CS: An ordered set of values One name, multiple values, in numbered order Can get to individual items if you know their position How would this be helpful in the QuizMe Hack?
Loops Tell the computer to do something over and over The block of code to repeat is IN the loop. Other code is not in the loop There must be a condition for the loop to end Example: Shopping List
Definite Loops Foreach (member of a list): do something Automatically end at the end of the list Example: foreach (class period): go to class foreach (shopping list item): get it Automatically move to the next member of the list at the end of the commands
Indefinite loops While (condition is true): do something End when the condition is not true Example: While (it is raining): use an umbrella Do not move through a list, just check a condition at the end of the block of code Can use a counter to keep track Example: While (I still have tickets): give next person a ticket