Question Bank Class 12 for Computer Science

 

Q. 1  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

Correct Answer : c) 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”

Correct Answer : b) “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)

Correct Answer : c) writer(fh)

 

 

Also Check : Another Subject’s Question Banks Below

>>>English Core

>>>Mathematics

>>>Chemistry

>>>Accountancy

>>>Business Studies

>>>Economics

>>>Physical Education

 

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved
error: Content is protected !!