Answer:
file = open('My_data.txt', 'w')
file.write('This file contains data')
Step-by-step explanation:
Required
The correct syntax to write to file
From the question, we understand that we are to write to file and not append to the file.
This implies that the access mode will be w which stands for write
The first line of (a), (b) and (c) is correct.
(d) is incorrect
Solving further,
Only values of type string (i.e. str) can be written to file
With this, we can conclude that:
(a) is correct because 'This file contains data' is of type string
(b) and (c) are incorrect because, in (b), the value is of type integer and in (c), the type is list