Bird
0
0

Which of the following is the correct way to flush output immediately in Python's print function?

easy📝 Syntax Q12 of 15
Python - File Reading and Writing Strategies
Which of the following is the correct way to flush output immediately in Python's print function?
A<code>print('Hello', flush=True)</code>
B<code>print('Hello', flush=False)</code>
C<code>print('Hello').flush()</code>
D<code>print.flush('Hello')</code>
Step-by-Step Solution
Solution:
  1. Step 1: Recall print function syntax

    Python's print function accepts a flush parameter to control flushing.
  2. Step 2: Identify correct usage

    Using flush=True inside print flushes output immediately.
  3. Final Answer:

    print('Hello', flush=True) -> Option A
  4. Quick Check:

    flush=True flushes output immediately [OK]
Quick Trick: Use flush=True inside print to flush output [OK]
Common Mistakes:
  • Trying to call flush() on print result
  • Using flush=False which disables flushing
  • Incorrect method call syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes