QuestionQ202

VerifiedControl Flow – Conditional Blocks and Loops

Drag and drop the conditional expressions to create code that displays *** on the screen. Some code boxes will not be used.

Drag & Drop
depth = 42 - 84 / 2
if depth > 0
    print("*")
elif :
    print("***")
elif :
    print("****")
Explanation

The calculation assigns 0 to depth. The first condition is false, while depth == 0 is true, causing the print("***") branch to run. Because an elif chain stops at its first true condition, the later depth < 0 branch is not executed.

Community Discussion

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