File Handling (Cambridge (CIE) IGCSE Computer Science)

Flashcards

1/10
  • Front

    What is file handling?

Enjoying Flashcards?
Tell us what you think

Cards in this collection (10)

  • What is file handling?

    File handling is the use of programming techniques to work with information stored in text files.

  • List four examples of file handling techniques.

    1. Opening text files

    2. Reading text files

    3. Writing text files

    4. Closing text files.

  • In Python, how do you open a file named "fruit.txt" in read mode?

    file = open("fruit.txt","r")

  • How do you close a file in Python?

    file.close()

  • What does the "a" mode mean when opening a file in Python?

    The "a" mode is for writing to the end of an existing file only (append).

  • True or False?

    The "w" mode in Python will create a new file if it doesn't exist.

    True.

    The "w" mode in Python will create a new file if it doesn't exist.

  • What is the purpose of the readline() function in Python?

    The readline() function is used to read a single line from a file.

  • How do you write a new line to a file in Python?

    file.write("New line content\n")

  • What does the following code do:

    endOfFile = name == ""

    It checks if the end of the file has been reached by seeing if the 'name' variable is empty.

  • True or False?

    It's important to always make a backup of text files you are working with.

    True.

    It's important to always make a backup of text files you are working with, as one mistake can cause you to lose the contents.