Group 4 - 3.8 and 3.10 Iterations and Pseudocode
Hacks
Notes
- An iteration is a repeating portion of an algorithm that repeats until a condition is met.
- An iteration statement changes the flow of control until a condition allows it to stop
- “Repeat until” does exactly what it says, it repeats until the condition is false.
- Stopping conditions are oftentimes necessary within an iteration.
- While statements help to complete an action until a condition becomes false, for example we can print hello while i is less than 6, but once it becomes more than 6 it stops.
- An iteration is a part of an algorithm and stopping conditions help to stop an iteration.
- An iteration statement causes statements to be executed 0 or more times
- Range functions can help to restrict what is printed, starting from 0 and going until the number before the ranges number.
- If you want to restrict the lower bound to not be 0 you can print from (x,y)
- While loops allow variation as well but can be formatted differently.
- “for loops” will complete the function within the for loop until the condition given is no longer met.
- The purpose of this code is to simplify code making it easier to create long strings of code.
- List expressions use list indexing and list procedures
- List procedures are implemented in accordance with the syntax rules of the language used
- AP exam will use pseudocode for loops
- Traversing a list visits each element in order which can help to identify an element within a list.
- A given element of a list can ve evaluated using “[ ]”
Hacks
3.8.1
- 1: Define an iteration
- An iteration is a repeating portion of an algorithm that repeats until a condition is met.
- 2: Make an example of an iteration
- Lets say that I am looking for the plane that I need to board, starting with 1 and going to 10.
- I can start searching at gate 1 for the plane that I need to board
- Each time I increase the gate number by 1 until I find the plane that I need to board
- Then I stop using a break function or in this case, just stopping and getting on the plane.
- 3: Program a simple iteration
- 1: What is an iteration statement
- An iteration is a part of an algorithm that repeats until a condition is met.
- 2: Create a descending list of numbers using for loop
- Using while loop, make a list of numbers which will form an output of 3,16,29,42,55,68,81 3.10
- Find Lowest value
- Quiz