QuestionQ178

VerifiedControl Flow – Conditional Blocks and Loops

How many hash (#) characters does this code print to the screen?

Question Image

Explanation

Integer floor division changes floor from 10 to 2, then from 2 to 0, so the loop prints two hash characters. Because the loop ends without a break, the loop else clause also runs and prints one more, producing three hashes total.

Community Discussion

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