Week 4 Unit 4: Self-test

18. June 2024

Question 1

Which of the following statements about writing data to a file are correct?

Note: There are 3 correct answers to this question.


When writing new data to a file, it is not necessary to close the file.
To not store all data in one line, line breaks "\n" have to be added explicitly.
Before writing data to a file, the ".strip()" method should be used to avoid unnecessary spaces.
The only data type which can be written to a file is string. All other data types have to be converted first.
If complex data stored in a tuple is to be written to a file, then all elements of the tuple first have to be converted into strings. In a second step, these strings are concatenated into one string so that the complete tuple is in one line of the file.

< Previous unit | Next unit > | Course Overview