Using a continue in a while loop causes the loop to break the current iteration and start the next iteration of the loop.
You have to choose 1 option:
The answer given was True.
I have doubt about the correctness about this answer, because if you use continue with label, yes, the continue statement will break the current iteration, but it might not cause the start of next iteration of the loop. So IMO the answer should be False. I have the following code to demonstrate my point:
The print out is, as you can see the output, the continue statement caused the labeled block to execute again.
May be you put a print statement right after your outer-for-loop starts and see for yourself if the loop-local variable j is incremented or not.. if you see j incrementing, then you can conclude that 'continue' actually starts the next iteration rather than executing the whole loop from the start.
posted 7 years ago
Good suggestion. After I inserted the print statement at the end of the outer for loop like following, it did not get executed, the printout stays the same. This means the continue + label cause the outer for loop to start all over again.
Keep in mind that the test is for programmers -- not lawyers. There will be questions that will have some edge conditions. In this case, you are assuming a label loop (although none is mentioned), and then assuming the loop being referred to isn't the label loop that you assumed earlier. If the question mentioned labels, then okay, but otherwise, I think it is safer to assuming the more common case.
You only have so much time for the test. Play a bit of the percentages here is probably good. And over thinking the question is probably bad.