Bird
Raised Fist0

Identify the error in this code that tries to flush output:

medium📝 Debug Q14 of Q15
Python - File Reading and Writing Strategies
Identify the error in this code that tries to flush output:
print('Start')
print('Middle', flush=False)
print('End', flush=True)
Aprint cannot have flush parameter
Bflush=False disables flushing, so 'Middle' may delay output
Cflush=True is invalid syntax in print
DMissing import for flush
Step-by-Step Solution
Solution:
  1. Step 1: Check flush parameter usage

    flush=True or flush=False are valid in print since Python 3.3.
  2. Step 2: Understand flush=False effect

    flush=False means output may be buffered and delayed, so 'Middle' might not appear immediately.
  3. Final Answer:

    flush=False disables flushing, so 'Middle' may delay output -> Option B
  4. Quick Check:

    flush=False delays output [OK]
Quick Trick: flush=False delays output; flush=True forces immediate output [OK]
Common Mistakes:
MISTAKES
  • Thinking flush=True is invalid
  • Assuming print can't flush
  • Expecting flush to require import

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes