ComputerScienceXIIf
ComputerScienceXIIf
Subject: COMPUTER SCIENCE iv. Identify the suitable code for blank space in line marked as Statement-4.
Q. No. 1 Rohit, a student of class 12th, is learning CSV File Module in Python. During a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
examination, he has been assigned an incomplete python code (shown below) b) ROLL_NO, NAME, CLASS, SECTION
to create a CSV File 'Student.csv' (content shown below). Help him in c) 'roll_no','name','Class','section'
completing the code which creates the desired CSV File. d) roll_no,name,Class,section c) co.connect()
Q. No. 5 In a Database, there are two tables with the instances given below: a. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS
WHERE CLASS LIKE “12%” AND STUDENTS.ADMNO
Table: STUDENTS =SPORTS.ADMNO;
ADMNO NAME CLASS SEC RNO ADDRESS PHONE b. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS
WHERE CLASS LIKE “12%” AND STUDENTS.ADMNO=
1211 MEENA 12A D 4 A-26 3245678
SPORTS.ADMNO;
1212 VANI 10A D 1 B-25 5456789 c. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS
1213 MEENA 12B A 1 NULL NULL WHERE CLASS LIKE “12%” AND ADMNO.STUDENTS
1214 KARISH 10B B 3 AB-234 4567890 =ADMNO.SPORTS;
d. SELECT NAME, COACHNAME FROM STUDENTS, SPORTS
Table: SPORTS WHERE CLASS LIKE= “12%” AND STUDENTS.ADMNO
ADMNO GAME COACHNAME GRADE =SPORTS.ADMNO;
1215 CRICKET MR. RAVI A
1213 VOLLEYBALL MR. AMANDEEP B Correct Answer:
1211 VOLLEYBALL MR. GOVARDHAN A a. SELECT NAME, COACHNAME FROM STUDENTS,SPORTS WHERE
CLASS LIKE “12%” AND STUDENTS.ADMNO=SPORTS.ADMNO ;
1212 BASKET BALL MR TEWARI B
iv. which two select queries will give the same output
Correct Answer: c) load(f) You as an expert of Python have to provide the missing statements and other
iv. What will be the suitable code for blank space in line marked as Statement-4. related queries based on the following code of Radha.
a) rec[0]==2 Answer any four questions (out of five) from the below mentioned questions.
b) rec[1]==2 i. Choose the appropriate mode in which the file is to be opened in append mode
c) rec[2]==2 (Statement 1)
d) rec[0]==1 a. w+
b. ab
Correct Answer: d) rec[0]==1 c. r+
v. Which statement Arun should use at blank space in line marked as Statement- d. a
4 to close the file.
a) file.close() Correct Answer: d. a
b) close(file) ii. Which statement will be used to create a csv writer object in Statement 2.
c) f.close() a. csv.writer(csvf)
d) close() b. csv.writer(csvf)
c. csvf.writer()
Correct Answer: c) f.close() d. cs.writer(csvf)
Q. No. 9 Radha Shah is a programmer, who has recently been given a task to write a Correct Answer: b. csv.writer(csvf)
python code to perform the following CSV file operations with the help of two iii. Choose the correct option for Statement 3 to write the names of the column
user defined functions/modules: headings in the CSV file, BOOKS.CSV.
a. cw.writerow('Title','Author','Price')
a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode b. cw.writerow(['Title','Author','Price'])
containing information of books – Title, Author and Price. c. cw.writerows('Title','Author','Price')
b. CSVRead() : to display the records from the CSV file called d. cw.writerows(['Title','Author','Price'])
BOOKS.CSV where the field title starts with 'R'.
She has succeeded in writing partial code and has missed out certain statements, Correct Answer: b. cw.writerow(['Title','Author','Price'])
so she has left certain queries in comment lines. iv. Which statement will be used to read a csv file in Statement 4.
a. cs.read(csvf)
import csv b. csv.reader(csvf)
def CSVOpen(): c. csvf.read()
with open('books.csv','______',newline='') as csvf: d. csvf.reader(cs)
#Statement-1
cw=______ #Statement-2 Correct Answer: b. csv.reader(csvf)
______ #Statement-3
cw.writerow(['Rapunzel','Jack',300])
v. Fill in the appropriate statement to check the field Title starting with ‘R’ for
cw.writerow(['Barbie','Doll',900]) Statement 5 in the above program.
cw.writerow(['Johnny','Jane',280]) a. r[0][0]=='R'
b. r[1][0]=='R'
def CSVRead(): c. r[0][1]=='R'
d. d) r[1][1]=='R' d. not Empty
def FilterWords():
c=0
file=open('NewsLetter.TXT', '_____') #Statement-1
line = file._____ #Statement-2
word = _____ #Statement-3
for c in word:
if _____: #Statement-4
print(c)
_________ #Statement-5
FilterWords()
i. Write mode of opening the file in statement-1?
a. a
b. ab
c. w
d. r
Correct Answer: d. r
ii. Fill in the blank in statement-2 to read the data from the file.
a. File.Read()
b. file.read()
c. read.lines( )
d. readlines( )