Notes Sections 8-10
Home | API | Notes |
1) Iteration: a repeating portion of an algorithm, repeats a specified number of times or until a given condition is met
2) Iteration Statements: change the sequential flow of control by repeating a set of statements zero or more times, until a stopping condition is met
3) Repeat Until: if the condition evaluates to true initially, the loop body is not executed at all, due to the condition being checked before the loop
- For list operations, write expressions that use list indexing and list procedures
- For algorithms involving elements of a list, write iteration statements to traverse a list
- For list operations, evaluate expression that use list indexing and list procedures
- For algorithms involving elements of a list, determine the result of an algorithm that includes list traversals
- List procedures are implemented in accordance with the syntax rules of the programming language
Iteration Statements can be used to traverse a list
AP EXAM provides pseudocode for loops
- Knowledge of existing algorithms that use iteration can help in constructing new algorithms
nums = ["10", "15", "20", "25", "30", "35"]
potentialMin = int(nums.pop())
while len(nums) != 0:
newNum = int(nums.pop())
if newNum < potentialMin:
potentialMin = newNum
print(potentialMin, "is the minimum value.")
fruit = ["apple", "orange", "strawberry", "pear"]
i = 0
for x in fruit:
print(fruit[i])
i += 1