Q22Single correct3 Marks24 Dec 2023
Each entry in `L` corresponds to a student and the marks he or she has scored in a Python exam. Write these details to a CSV file named `scores.csv`. The header should be `Name,Python`. The entries should be written to the file in the order in which they appear in the list `L`. Select the correct implementation of a function named `write_to_file` that accepts `L` as argument and writes to the file `scores.csv`.
L = [('Arjun', 75), ('Anita', 85), ('Atul', 80), ('Anwer', 75), ('Andrew', 80)]
Snippet-1
```
def write_to_file(L):
f = open('scores.csv', 'w')
f.write('Name,Python\n')
for i in range(len(L)):
name, marks = L[i]
line = name + ',' + marks
if i != len(L) - 1:
line = line + '\n'
f.write(line)
f.close()
```
Snippet-2
```
def write_to_file(L):
f = open('scores.csv', 'w')
f.write('Name,Python\n')
for i in range(len(L)):
name, marks = L[i]
line = name + ',' + str(marks)
if i != len(L) - 1:
line = line + '\n'
f.write(line)
f.close()
```