Question

    What is the purpose of the with statement when working

    with files?
    A To open a file in write mode Correct Answer Incorrect Answer
    B To open a file in read mode Correct Answer Incorrect Answer
    C To ensure that a file is properly closed after it is no longer needed Correct Answer Incorrect Answer
    D To delete a file Correct Answer Incorrect Answer
    E To rename a file Correct Answer Incorrect Answer

    Solution

    Explanation: The with statement is used to ensure that a file is properly closed after it is no longer needed. This is important because

    Practice Next