1. A "for" loop is typically used when the number of loop cycles is known.
Correct. Use a "for" loop to cycle through a specified number of times.
Incorrect. Use a "while" loop when the number of cycles is based on a condition, not number of cycles.
2. To skip an individual cycle of a for loop, the following command is used:
Incorrect. break terminates the loop
Correct. continue initiates the next cycle of the loop
Incorrect. Use a "continue" statement
Incorrect. Use a "continue" statement
3. What will the following code print as a result for sum?
sum = 0
for i in range(5):
if i==3:
continue
sum = sum + i
print(sum)
Incorrect. Skip the 3 for 0+1+2+4 = 7
Incorrect. Skip the 3 for 0+1+2+4 = 7
Correct. Skip the 3 for 0+1+2+4 = 7
Incorrect. Skip the 3 for 0+1+2+4 = 7