Interview quiz track

First 2 free Junior Python

Python – File Handling

Practice Python file handling interview questions covering reading, writing, and working with files. Write short code or explanations and receive feedback on correctness and best practices. Ideal for beginner Python interview prep. First 2 questions are free with full feedback.

  • Level Junior
  • Questions 12
  • Python
  • file handling
  • beginner
  • interview practice

Try any track free — first 2 questions include full AI feedback. Subscribe to finish the track and unlock everything. Type or speak your answer — the first 2 questions include scoring and detailed AI feedback.

Try first 2 questions free All tracks

Sample python – file handling interview questions

Preview 6 questions from this track in quiz order. In the full quiz you answer one at a time — type or speak — then get a score and feedback.

  1. How do you open and read a file in Python?

    What a strong answer includes

    Uses open() and preferably a with statement.

  2. What is the benefit of using a with statement when working with files?

    What a strong answer includes

    Automatically closes the file.

  3. How do you write to a file?

    What a strong answer includes

    Opens in write mode and writes content.

  4. What is the difference between read(), readline(), and readlines()?

    What a strong answer includes

    Whole file, one line, or list of lines.

  5. How do you append to a file instead of overwriting it?

    What a strong answer includes

    Uses append mode ('a').

  6. Write code to count the number of lines in a file.

    What a strong answer includes

    Correct reading and counting.