Untitled
10 Questions
8 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

which one of the following is the right way to close a file?

  • file.close() (correct)
  • close(file)
  • close("file")
  • file.closed
  • if a file File.txt has 10 lines written in it, what will be the result of the following line? len(open("File.txt").readlines())

  • 0
  • 1
  • 5
  • 10 (correct)
  • a file is stored in ____ memory

  • primary
  • cache
  • volatile
  • secondary (correct)
  • what will happen when a file is opened in write mode and then immediately closed?

    <p>file contents are deleted</p> Signup and view all the answers

    which one of the following is the right way to write "Good Morning" in a file?

    <p>file.write(&quot;Good Morning&quot;)</p> Signup and view all the answers

    which method is used to read a single line from the file?

    <p>readline()</p> Signup and view all the answers

    the default access mode is _______

    <p>r</p> Signup and view all the answers

    by default, a new file is created in which directory?

    <p>current working directory</p> Signup and view all the answers

    what is the purpose of the with statement in python file handling?

    <p>to ensure that a file is properly closed after its operations are completed</p> Signup and view all the answers

    what is the purpose of the see() method in python file handling?

    <p>to set the current position in a file</p> Signup and view all the answers

    Use Quizgecko on...
    Browser
    Browser