Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
8.8k views
in Computer by (15.9k points)

Rohit, a student of class 12th, is learning CSV File Module in Python. During examination, he has been assigned an incomplete python code (shown below) to create a CSV File 'Student.csv' (content shown below). Help him in completing the code which creates the desired CSV File. 

CSV File 

1,AKSHAY,XII,A 

2,ABHISHEK,XII,A 

3,ARVIND,XII,A 

4,RAVI,XII,A 

5,ASHISH,XII,A

Incomplete Code 

import_____ #Statement-1 

fh = open(_____, _____, newline='') #Statement-2 

stuwriter = csv._____ #Statement-3 

data = [] 

header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION'] 

data.append(header) for i in range(5):

roll_no = int(input("Enter Roll Number : ")) 

name = input("Enter Name : ") 

Class = input("Enter Class : ") 

section = input("Enter Section : ") 

rec = [_____]      #Statement-4 

data.append(rec) stuwriter. _____ (data)      #Statement-5

fh.close()

i. Identify the suitable code for blank space in line marked as Statement-1. 

a) csv file 

b) CSV 

c) csv 

d) Csv 

ii. Identify the missing code for blank space in line marked as Statement-2? 

a) "School.csv","w" 

b) "Student.csv","w" 

c) "Student.csv","r" 

d) "School.csv","r" 

"Student.csv","w" 

iii. Choose the function name (with argument) that should be used in the blank space of line marked as Statement-3 

a) reader(fh) 

b) reader(MyFile) 

c) writer(fh) 

d) writer(MyFile)

iv. Identify the suitable code for blank space in line marked as Statement-4. 

a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION' 

b) ROLL_NO, NAME, CLASS, SECTION 

c) 'roll_no','name','Class','section' 

d) roll_no,name,Class,sectionc) co.connect()

v. Choose the function name that should be used in the blank space of line marked as Statement-5 to create the desired CSV File? 

a) dump() 

b) load() 

c) writerows() 

d) writerow()

Please log in or register to answer this question.

1 Answer

+1 vote
by (15.3k points)
edited by

1. Correct Answer : c) csv

2. Correct Answer : b) "Student.csv","w"

3. Correct Answer : c) writer(fh)

4. Correct Answer : d) roll_no,name,Class,section

5. Correct Answer : c) writerows()

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...