nerdexam
Python_Institute

PCEP-30-02 · Question #361

Drag and drop the conditional expressions to obtain a code which outputs ** to the screen. (Note: some code boxes will not be used.)

The code calculates rate = 21 2 // 1, which results in rate = 42. To logically match the visual solution provided (which prints '*' when rate is 42), the conditions should be arranged as: if rate > 42: print('') elif rate == 42: print('') else: print(''). Note: The question…

Module 3: Boolean Values, Conditional Execution, Loops, Lists and List Processing, Logical and Bitwise Operations

Question

Drag and drop the conditional expressions to obtain a code which outputs ** to the screen. (Note: some code boxes will not be used.)

Explanation

The code calculates rate = 21 * 2 // 1, which results in rate = 42. To logically match the visual solution provided (which prints '***' when rate is 42), the conditions should be arranged as: if rate > 42: print('*') elif rate == 42: print('***') else: print('****'). Note: The question asks for output **, but the elif branch from the provided solution would print *** if executed with rate = 42. This indicates a possible discrepancy between the question's requested output and the solution's code effect.

Topics

#conditional expression#boolean logic#nested conditions#output tracing

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice