Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What function do you use to open a file in Python?
Think of the command used to access files in Python.
What mode do you use to open a file for writing?
Remember that w stands for a specific action.
What is the mode used to open a file for writing in Python?
It’s the first letter of 'write'.
Context managers are used to automatically handle which of the following?
Think about what happens to resources when you're done using them.
Create a Python function that takes a file name and writes multiple lines of text to it. Ensure it handles cases where the file already exists.
Consider how to manage existing files and whether to overwrite them.
Write a piece of code that reads a CSV file and prints each row. Explain how you would handle exceptions if the file is not found.
Think about the mechanism to alert the user when the file doesn’t exist.
6 more questions in this section. Enroll free to practise them all.
Enroll free