Vocabulary

  • Iteration: the repitition of a process.
  • For Loop: repeats a function for a set number of times; I is the number of times repeated. With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.
  • While Loop: the while loop is used to repeat a section of code an unknown number of times until a specific condition is met. A while loop will execute a set of statements as long as a condition is true.
  • Initialization: whatever sets the counter variable to a starting value.
  • Condition: allows the computer to know whether or not to keep repeating the loop.
  • Increment/Decrement: modifies the counter variable after each repetition.

  • Indexing/List Index: position of an element in a list, starting from 0.
  • Append, Remove, Pop: append adds an element to the end, removes an index or selected index, and pop removes the last item of an index.
  • Elements: an item in a list.
  • Nesting: having one data type or function inside another data type or function.
  • array - alternate name for a list.

What are Lists?

  • Lists are a collection of data in a sequence that is an iterable
  • Each sequence is demarcated with an index, starting from 0. [0, 1, 2]
  • It is stored as a variable name with multiple pointers to each variable stored in a certain order
  • Lists have methods that act upon the list and change them. This moves the pointers within RAM to change the parts of the list.

A MASSIVE NOTE: Lists methods Mutate, meaning they actively change the list, but they don’t return anything. This means that return a None-type, which you cannot manipulate

Hacks

Excercises

Multiple Choice Correction

Question 8

A while loop, loops over a bound interval by comparing a conditional. A while loop will execute a set of statements as long as a condition is true.

Question 9

A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.