CBSE
Board Central Board of Secondary Education [CBSE]
Class 12th / XII
Download Question Bank
Subject Computer Science
Document Type PDF
Official Website http://cbseacademic.nic.in/

CBSE Class XII Computer Science Question Bank

Central Board of Secondary Education [CBSE] Class 12th Computer Science Question Bank With Answer Key

Download CBSE Class 12th All Subjects Question Bank With Answer Key 2021 Here

Download Class 12th Computer Science Question Bank

Class & Subjects Question Bank
Class XII Computer Science
Download

CBSE Class XII Computer Science Sample Questions

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()

2. 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)

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()

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

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()

Correct Answer : c) writerows()

2. Amritya Seth is a programmer, who has recently been given a task to write a python code to perform the following binary file operations with the help of two user defined functions/modules:

a. AddStudents() to create a binary file called STUDENT.DAT containing student information – roll number, name and marks (out of 100) of each student.

b. GetStudents() to display the name and percentage of those students who have a percentage greater than 75. In case there is no student having percentage > 75 the function displays an appropriate message. The function should also display the average percent.

He has succeeded in writing partial code and has missed out certain statements, so he has left certain queries in comment lines. You as an expert of Python have to provide the missing statements and other related queries based on the following code of Amritya.

Answer any four questions (out of five) from the below mentioned questions.
import pickle
def AddStudents():
____________ #1 statement to open the binary file to
write data
while True:
Rno = int(input(“Rno :”))
Name = input(“Name : “)
Percent = float(input(“Percent :”))
L = [Rno, Name, Percent]
____________ #2 statement to write the list L
into the file
Choice = input(“enter more (y/n): “)
if Choice in “nN”:
break
F.close()
def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open(“STUDENT.DAT”,”rb”) as F:
while True:
try:
____________ #3 statement to read
from the file
Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], ” has percent =
“,R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print(“There is no student who has
percentage more than 75″)
average=Total/Countrec
print(“average percent of class = “,average)
AddStudents()
GetStudents()

i. Which of the following commands is used to open the file “STUDENT.DAT” for writing only in binary format? (marked as #1 in the Python code)
a. F= open(“STUDENT.DAT”,’wb’)
b. F= open(“STUDENT.DAT”,’w’)
c. F= open(“STUDENT.DAT”,’wb+’)
d. F= open(“STUDENT.DAT”,’w+’)

Correct Answer : a. F= open(“STUDENT.DAT”,’wb’)

ii. Which of the following commands is used to write the list L into the binary file, STUDENT.DAT? (marked as #2 in the Python code)
a. pickle.write(L,f)
b. pickle.write(f, L)
c. pickle.dump(L,F)
d. f=pickle.dump(L)

Correct Answer : c. pickle.dump(L,F)

iii. Which of the following commands is used to read each record from the binary file STUDENT.DAT? (marked as #3 in the Python code)
a. R = pickle.load(F)
b. pickle.read(r,f)
c. r= pickle.read(f)
d. pickle.load(r,f)

Correct Answer : a. R = pickle.load(F)

Similar Searches:
cbse question bank 2021 class 12 , cbse question bank class 12 , cbse question bank 2021 , cbse question bank 2021 class 12 cbse nic , cbse question bank 2021 class 12 pdf, cbse question bank answers , cbse question bank answer key , cbse academic question bank , cbse academic question bank class 12 , cbse accountancy question bank , question bank by cbse , cbse board question bank , cbse board question bank 2021 , cbse question bank class 12 2021 , cbse question bank for class 12 , cbse question bank for class 12 2021 , cbse question bank for class 12th

Have a question? Please feel free to reach out by leaving a comment below

(Visited 2,747 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *