My Portions:
I worked on all the Pseudo Code for the popcorn hacks I also worked on nested if statements and continue/break
Nested If Statements You can nest conditional statements inside a for loop to execute different code based on conditions.
APCSP Pseudo-Code: For Loop with Nested If Statements
numbers ← [1, 2, 3, 4, 5] FOR EACH num IN numbers: IF num MOD 2 EQUALS 0: DISPLAY num, “is even” ELSE: DISPLAY num, “is odd” END IF END FOR
# Example 6: For loop with nested if statements
numbers = [1, 2, 3, 4, 5]
for num in numbers:
if num % 2 == 0:
print(num, "is even")
else:
print(num, "is odd")
1
2
4
Continue + break Continue and Break Continue statement skips the current iteration Break statement exits the loop prematurely
APCSP Pseudo-Code: For Loop with Continue and Brea
# Example 8: For loop with continue and break
numbers = [1, 2, 3, 4, 5]
for num in numbers:
if num == 3:
continue # Skip the number 3
if num == 5:
break # Exit the loop when 5 is encountered
print(num)