Bird
0
0

You want to create a program that reads a text file and counts how many lines contain the word 'error'. Which standard library module would help you open and read the file easily?

hard📝 Application Q15 of 15
Python - Standard Library Usage
You want to create a program that reads a text file and counts how many lines contain the word 'error'. Which standard library module would help you open and read the file easily?
Are
Bsys
Cos
Dio
Step-by-Step Solution
Solution:
  1. Step 1: Identify the task requirements

    The program needs to open and read a text file line by line.
  2. Step 2: Choose the module for file input/output

    The io module provides tools to open and read files easily in Python.
  3. Step 3: Understand other options

    os handles operating system tasks, sys deals with system-specific parameters, and re is for regular expressions, not file reading.
  4. Final Answer:

    io -> Option D
  5. Quick Check:

    File reading needs io module = A [OK]
Quick Trick: Use io module to open and read files easily [OK]
Common Mistakes:
  • Choosing os or sys for file reading
  • Confusing re module with file handling
  • Not knowing which module handles file I/O

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes