Unit 3.8 & 3.10 Hacks
HACKS Unit 3 Section 8
Hacks Unit 3 Section 3.8.1
- Define an Iteration Portion of code segments that repeat until the requirement is met
- Make your own example of an iteration with at least 4 steps and a stopping condition(Similar to mine that I did)
- I have n homeworks to do
- Start and finish homework assignment
- Move onto next homework assignment
- Repeat steps 2-3 until there is no more homework
- Program a simple iteration.
fruit = ["apple", "orange", "strawberry", "pear"]
i = 0
for x in fruit:
print(fruit[i])
i += 1
for x in range(10, -1, -1):
print(x)
- Using while loop, make a list of numbers which will form an output of 3,16,29,42,55,68,81
for x in range(3, 94, 13):
print(x)
HACKS Unit 3 Section 10
- Find the lowest value in a list (Luna Iwazaki)
- Use the list made below
- Make a variable to hold the minimum and set it to potential minimum value
- Loop
- Check each element to see if it is less than the minimum variable
- If the element is less than the minimum variable, update the minimum
- After all the elements of the list have been checked, display the minimum value
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.")
- Lists Quiz (Ethan Tran) Take a screenshot of your score on put it on your review ticket!