QuestionQ60

VerifiedControl Flow – Conditional Blocks and Loops

What occurs when the user executes the following code?

Question Image

Explanation

range(5) produces the values 0 through 4, and only 1 and 3 satisfy i % 2 == 1, so total becomes 2. A for statement’s else suite runs when the loop finishes normally without a break, reducing total to 1 before it is printed.

Community Discussion

No comments yet. Be the first to start the discussion!