Students must start practicing the questions from CBSE Sample Papers for Class 12 Computer Science with Solutions Set 5 are designed as per the revised syllabus.

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Time Allowed: 3 hours
Maximum Marks: 70

General Instructions:

  • This question paper contains five sections, Section A to E.
  • All questions are compulsory.
  • Section A have 18 questions carrying 01 mark each.
  • Section B has 07 Very Short Answer type questions carrying 02 marks each.
  • Section C has 05 Short Answer type questions carrying 03 marks each.
  • Section D has 03 Long Answer type questions carrying 05 marks each.
  • Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only.
  • All programming questions are to be answered using Python Language only.

Section – A

Question 1.
State True or False.
**is a valid arithmetic operator in Python.
Answer:
True

Explanation:
Python supports arithmetic operators that are used to perform the four basic arithmetic operations as well as modular division, floor division and exponentiation.

(Exponent): Performs exponential (power) calculation on operands. That is, raise the operand on the left to the power of the operand on the right.

Question 2.
Which of the following is an invalid variable? [1]
(A) my_string_1
(B) 1st_string
(C) foo
(D) _A
Answer:
Option (B) is correct.

Explanation:
Variable is an identifier that is used to represent specific data item. The data item may be a whole number, a fractional number, a sequence of character, a single character etc.
1st_string is invalid because variable’s name cannot be start with a digit.

Question 3.
In Python, defines a block of statements. [1]
(A) Block
(B) loop
(C) indentation
(D) {}
Answer:
Option (C) is correct.

Explanation:
Python uses indentation for block as well as for nested block structures. Leading whitespace (spaces and tabs) at the beginning of a statement is called indentation.
In Python, the same level of indentation associates statements into a single block of code. The interpreter checks indentation levels very strictly and throws up syntax errors if indentation is not correct.

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Question 4.
Using a wrong formula for calculation generates a : [1]
(A) Syntax error
(B) Semantic error
(C) Logical error
(D) Runtime error
Answer:
Option (C) is correct.

Explanation:
A logical error is a mistake in a program’s source code that results in incorrect result or unexpected behaviour. It may simply produce the wrong output or may cause a program to crash while running.

Commonly Made Error
Students do not have a clear Idea of what ! different types of error are.

Answering Tip
Students should learn the errors and their I examples error occurs due to abnormal operation performed by a program.

Question 5.
Division by zero is an example of : [1]
(A) Run time error
(B) Compile time error
(C) Syntax error
(D) All of these
Answer:
Option (A) is correct.

Explanation:
While executing the program, runtime error occurs due to abnormal operation performed by a program.

Question 6.
Consider a declaration L = (1,’ Python1, ‘ 3.14’). Which of the following represents the data type of L? [1]
(A) list
(B) tuple
(C) dictionary
(D) string
Answer:
Option (B) is correct.

Explanation:
Elements enclosed in parentheses() represents by tuple

Question 7.
Fill in the blank
____________ operator cannot be used with string data type [1]
(A) +
(B) in
(C) *
(D) I
Answer:
Option (D) is correct.

Explanation:
‘+’ is concatenation operator, ‘in’ is membership operator and ‘ *’ is replication operator. All these are used with strings. ‘/ is arithmetical operator hence cannot be used with strings.

Commonly Made Error
Students do not know about different categories of the operators.

Answering Tip
Operators and their uses should be understood ; and learnt properly

Question 8.
Which of the following function gives the total number of rows in a given column or expression? [1]
(A) SUM()
(B) COUNT()
(C) TOTAL()
(D) Both (A) and (B)
Answer:
Option (B) is correct.

Explanation:
The syntax of COUNT () function is COUNT ( {* [DISTINCT/ALL] expr})
Eg. SELECT COUNT (*) “Total records” FROM student;
The above example will return total number of records in table Student

Question 9.
Which keyword is used to define function? [1]
(A) def
(B) fun
(C) definition
(D) function
Answer:
Option (A) is correct.

Explanation:
A function is a block of organised and reusable code that is used to perform a single, related action. The function block begins with the keyword def followed by the function name.

Question 10.
Fill in the blank
____________ refers to the attribute that can uniquely identify tuples within the relation. [1]
(A) Foreign key
(B) Consolidate key
(C) Alternate Key
(D) Primary key
Answer:
Option (D) is correct.

Explanation:
A primary key in a table is a column or a group of columns that uniquely identify every row in that table. The Primary Key can’t be a duplicate i.e., The same value cannot appear more than once in the table, e.g., Student’s roll number, Product ID etc.

Commonly Made Error
Students suppose that primary key is a single field.

Answering Tip
It should be clearly noted that primary key can I also be a group of fields.

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Question 11.
Which of the following is the default character for the newline parameter for a csv file object opened in write mode in Python IDLE ? [1]
(A) \n
(B) \t
(C) ,
(D) ;
Answer:
Option (A) is correct.

Explanation:
If newline=” is not specified, newlines embedded inside quoted fields will not be interpreted correctly, and on platforms that use \r\n line endings on write an extra \r will be added. It should always be safe to specify newline=”\n”, since the csv module does its own (universal) newline handling.

Question 12.
Fill in the blank
To get all the records from the result set, you may use: [1]
(A) cursor.fetchmany()
(B) cursor.fetchall()
(C) select * from < table name>
(D) cursor.execute ()
Answer:
Option (B) is correct.

Explanation:
The fetchall() method will return all the rows from the resultset in the form of a tuple _ containing the records.

Question 13.
Fill in the blank
The function of a repeater is to take a weak and corrupted signal and it. [1]
(A) restore
(B) regenerate
(C) amplify
(D) reroute
Answer:
Option (B) is correct.

Explanation:
A repeater is an electronic device which is a combination of a receiver and a transmitter. Its major function is to increase the range of communication signals received from the transmitter and to retransmit it.

Commonly Made Error
Students mix the concepts of repeaters, hubs and switches.

Answering Tip
Difference between repeaters, hubs switches should be clearly understood.

Question 14.
The data structure required to check whether an expression contains balanced parenthesis is: [1]
(A) Stack
(B) Queue
(C) Array
(D) Tree
Answer:
Option (A) is correct.

Explanation:
Stack is a simple data structure in which elements can be added and removed in a specific order. In other words, it follows a LIFO (Last In First Out) or a FILO (First In Last Out) structure.

Question 15.
Which of the following is invalid method for fetching the records from database in Python? [1]
(A) fetchone ()
(B) fetchmany ()
(C) fetchall ()
(D) fetchmulti ()
Answer:
Option (D) is correct.

Explanation:
fetchone() will return one record from the resultset.
fetchall() will return all the records retrieved as per query.
fetchmany(<n>) will return n number of records from the resultset.

Question 16.
Which function is used with ORDER BY clause to custom sort order? [1]
(A) ASC
(B) DESC
(C) FIELD
(D) None of these
Answer:
Option (C) is correct.

Explanation:
The FIELD function internally maps the values specifying order to a list of numeric values and then uses those numbers for sorting.

Assertion and Reason:
In the following questions, A statement of Assertion (A) is followed by a statement of Reason (R). Mark the correct choice as.
(A) Both A and R are true and R is the correct explanation of A.
(B) Both A and R are true and R is not correct explanation of A.
(C) A is true but R is false.
(D) A is false but R is true.

Question 17.
Assertion (A): Strings in Python are mutable.
Reason (R): The first character has the index 0 and the last character has the index n-1 where n is the length of the string. [1]
Answer:
Option (D) is correct.

Explanation:
Indexing is used for accessing individual characters within a string. The first character has the index 0 and the last character has the index n-1 where n is the length of the string. The negative indexing ranges from -n to -1.
Strings in Python are immutable, i.e., a string cannot be changed after it is created.

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Question 18.
Assertion (A): Joining two lists is just like adding two strings.
Reason (R): The concatenation operator + is used to add two strings. [1]
Answer:
Option (A) is correct.

Explanation:
The concatenation operator + when used with two lists, joins them. The + operator when used with lists requires that both operands must be of list types. You cannot add any other value to a list.

Example:
>>>list1 = [1,2,3]
>>>list2 = [4,5,6]
>>>list1 +list2
[1,2,3,4,5,6]

Section – B

Question 19.
Rectify the error (if any) in the given statements. [2]
>>> str=”Hello Python”
>>> str [6] = ‘S’
Answer:
str[6] = ‘S’ is incorrect ‘str’ object does not support item assignment, str.replace(str[6], ‘S’)

Question 20.
What do you mean by a modem? Why is it used? [2]
OR
Explain the purpose of a router.
Answer:
A MODEM (Modulator Demodulator) is an electronic device that enables a computer to transmit data over telephone lines. It converts the digital signals, governed by the source computer into analog form for transmission over the telephone lines. At the receiving end it converts received lines into digital signals.
OR
A router establishes connection between two networks and it can handle network with different protocols. Using a routing table, routers make sure that the data packets are travelling through the best possible paths to reach their destination.

Question 21.
(a) What will be the output of the following Python code? [1]
V = 50
def Change (N) :
global V
V, N = N, V
print(V, N, sep=”#”,end=)
Change(20)
print(V)

(b) What is the output of the following Python code?
def ListChange ( ) :
for i in range (len (L) ) :
if L[i]%2 == 0:
L [i] =L [i] *2
if L [i] %3 == 0 :
L[i]=L [i] *3
else:
Lti] =L[i] *5
L = [2,6,9,10]
ListChange() for i in L:
print(i,end=’#’)
Answer:
(a) 20#50@20.
(b) 20#36#27#100#

Commonly Made Error
Sometimes students calculate the range and modulus values wrongly.

Answering Tip
Modulus(%) operator is used to find the remainder of a division. range() is used to iterate over a range of values.

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Question 22.
What is join in SQL?
Answer:
A join is a query that combines rows from two or more tables. In a join query, more than one tables are listed in FROM clause. The function of combining data from multiple tables is called joining. Joins are used when we have to select data from two or more tables.

Question 23.
(a) How is a domain name different from a URL ?
(b) Why is Internet not the world wide web ?
Answer:
(a) Domain names are used in URLs to identify particular web servers. For example, in the URL http://www. cbse.nic.in/welcome.htm, the domain name is www.cbse.nic.in.

(b) The Internet is a huge network of computers all connected together. The world wide web (www) is a collection of files, documents and other pages found on this network of computers.

Question 24.
Give the output of the following statements :
>>> str=”Honesty is the best policy”
>>> str.replace(‘o’,’*’)
OR
Write the output of the following code snippet
tup = (‘geek1,)
n = 5
for i in range (int (n) ) :
tup = (tup, )
print(tup)
Answer:
Honesty is the best policy
OR
(‘geek’,)
((‘geek’,),)
(((‘geek’,),),)
((((‘geek’,),),),)
(((((‘geek’,),),),),)

Question 25.
Differentiate between DDL & DML command. Identify DDL & DML command from the following: (UPDATE, SELECT, ALTER, DROP)
OR
In SQL, name the clause that is used to display the tuples in ascending order of an attribute and, what is the use of IS NULL operator?
Answer:
DDL stands for data definition language and comprises of command which will change the structure of database object.
DML stands for Data Manipulation Language and comprises of command which are used to insert, edit, view & delete the data stored in a database object.
DDL command: ALTER, DROP
DML command: UPDATE, SELECT

Commonly Made Error:
Difference between DDL and DML is not clear to students, so they are unable to classify the commands.

Answering Tip
DDL stands for data definition language and DML stands for data manipulation language.

Section – C

Question 26.
(a) Consider the table student given below
Table: STUDENT
CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions 1
Write output of the following query:
SELECT COUNT(*), City FROM STUDENT GROUP BY CITY HAVING COUNT(*)>1;
(b) write outputs for SQL queries (i) to (iv) Which are based on the table given below:
Table: TRAINS
CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions 2

Table: PASSENGERS
CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions 3
(i) SELECT MAX (TRAVELDATE), MIN (TRAVELDATE) FROM PASSENGERS WHERE GENDER= ‘FEMALE’
(ii) SELECT END, COUNT(*) FROM TRAINS GROUP BY END HAVING COUNT(*)> 1;
(iii) SELECT DISTINCT TRAVELDATE FROM PASSENGERS;
(iv) SELECT TNAME, PNAME FROM TRAINS T, PASSENGERS P WHERE T. TNO=E TNO AND AGE BETWEEN 50 AND 60; [1+2=3]
Answer:
(a)

COUNT(*) City
2 Mumbai
2 Delhi
2 Moscow

(b) (i)

MAX (TRAVELDATE) MIN(TRAVELDATE)
2018-11-10 2018-05-09

(ii)

END  COUNT(*)
Habibganj 2
Amritsar juction 2
New Delhi 4

Note: Values may be written in any order

(iii) DISTINCT TRAVELDATE
2018-12-25
2018-11-10
2018-10-12
2018-05-09
Note: Values may be written in any order
(iv)

TNAME PNAME
Amritsar Mail N S SINGH
Swarna Shatabdi R SHARMA

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Question 27.
Write a function to count the number of lines starting with a digit in a text file “Diary.txt”. [3]
OR
Write a function to read the content of a text file “DELHI.txt” and display all those lines on screen, which are either starting with ‘D’ or ‘M’.
Answer:

def CountFirstDigit() :
count=0
with open('Diary.txt','r') as f:
while True:
line=f.readline()
if not line:
break
if line[0] . isdigitO :
count = count+1
if count==0:
print ("no line starts with a digit")
else:
print ( "count = ",count)

OR

def CountDorM():
count=0
with open('DELHI.txt','r') as f:
while True:
line=f.readline()
if not line:
break
if line[0]=='D' or
line [0]=='M' :
count = count+1
print ("no line starts with D or M" )
else:
print ("count=",count)

Question 28.
(a) Find output for SQL queries (i) to (iv), which are based on given tables.
Table: DVD

DCODE DTITLE DTYPE
R101 Henry Martin Folk
E102 Dhrupad Classical
F101 The Planets Classical
f102 Universal soldier Folk
r102 A day in life rock

TABLE: MEMBER
CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions 4
(i) SELECT MIN (ISSUEDATE) FROM MEMBER;
(ii) SELECT DISTINCT DTYPE FROM DVD;
(iii) SELECT DCODE, Name, DTITLE FROM DVD D, MEMBER M WHERE D.CODE=M.DCODE;
(iv) SELECT DTITLE FROM DVD WHERE DTYPE NOT IN (“FOLK”, “CLASSICAL”);
(b) MySQL supports different character sets, which command is used to display all character sets? [3]
Answer:
(i) MIN (ISSUEDATE)
2016-12-13

(ii) DISTINCT DTYPE
Folk
Qassical
Rock

(iii)

DCODE NAME DTITLE
R102 AGAM SING A day in life
F102 ARTH JOSEPH Universal soldier
F101 NISHA HANS The planets

(iii) DTITLE A day in life

(b) SHOW CHARACTER SET

Question 29.
Write a program that uses a function which takes two string arguments and returns the string comparison result of the two passed strings. [3]
Answer:

def stringComp (str1, str2):
s1 = len(str1)
s2 = len(str2)
if (s1 ! = s2) :
return(False)
else:
for i in range s1
if str1[i]! = str2[i]:
return(False)
return (True)
fstring=input ("Enter First string:")
sstring=input ("Enter Second string:")
if stringComp (fstring, sstring):
print ("Strings are same")
else:
print ("Strings are different")

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Question 30.
Write a program to implement a stack for these book details (bookno, bookname). That is, now each item node of the stack contains two types of information -a bookno and its name. Just implement push and display operations. [3]
OR
Write a program to input any customer name and display customer phone number if the customer’s name exists in the list. A I
Answer:

def isempty(stk):
if stk==[]
return True
else:
return False
def pushbook (stk, item):
stk.append(item)
top=len (stk)-1
def displaybook(stk):
if isempty(stk):
print("Stack Empty")
else:
top=len (stk)-1
print ("book no book name")
for a in range (top,-1,-1):
print (stk[a])
stk= []
top=None
while True:
print ("book")
print("1. add a book")
print ("2. display list")
print ("3. exit")
ch=int (input("enter your choice 1-3 : ") )
if ch==1:
bno=input("enter book no:")
bname=input ("enter book name")
item=[bnp, bname]
pushbook (stk, item)
input ()
elif ch==2:
displaybook(stk)
input()
elif ch=3:
break
else:
print("invalid choice!")
input()

OR

def printlist(s):
i=0
for i in range(len(s)):
print (i,s [i])
i = 0
phonenumbers = ['9840012345', '9840011111', '9845622222','9850012345' , '9884412345']
flag=0
number = raw_input("Enter the phone number to be searched")
number = number.strip()
try:
i = phonenumbers.index(number)
if i >= 0:
flag=1
except ValueError:
pass
if (flag <>0) :
print ("\nphone number found in Phonebook at index", i)
else:
print('\iphonenumbernotfoundin Phonebook")
print( "\nPHONEBOOK")
printlist(phonenumbers)

Section – D

Question 31.
Meerut school in Meerut is starting up the network between it’s different wings. There are four buildings named as S, J, A and H. The distance between various buildings is as follows:

A to S 200 m
A to J 150 m
A to H 50 m
S to J 250 m
S to H 350 m
J to H 350 m

Number of computers in Each Building:

S 130
J 80
A 160
H 50

(i) Suggest the cable layout of connections between the buildings.

(ii) Suggest the most suitable place (i.e. building) to house the server of this school, provide a suitable reason.

(iii) Suggest the placement of the following devices with justification

  • Repeater
  • Hub/Switch

(iv) The organization also has inquiry office in another city about 50-60 km away in hilly region. Suggest the suitable transmission media to interconnect to school and inquiry office out of the following:

  • Fibre optic cable
  • Microwave
  • Radiowave

(v) The school is planning to link its buildings situated within 1 Km. Which type of network out of LAN, WAN, MAN will be formed? Justify. [5]
Answer:
(i)
CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions 5
(ii) Server can be placed in the A building as it has the maximum number of computers.
(iii) Repeater can be placed between A and S and A and J buildings as the distance is more than 110 m. Hub/switch should be placed in each building.
(iv) Radiowaves can be used in hilly regions as they can travel through obstacles.
(v) LAN (Local Area Network) as this network can be carried out within 1 km network.

Question 32.
(a) Find and write the output of the following Python code:

def Display(str):
m=””
for i in range(0,len (str)) :
if(str[i] .isupper ()) :
m=m+str[i].lower()
elif str[i] .islowerO :
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+”#”
print(m)
Display([email protected])

(b) Consider the tables Product and Client with structures as follows:

Product Client
PI_D CI_D
ProductName CName
Manufacturer CCity
Price CProd

Write Python codes to display the details of products whose price is in range of 50 to 100 (Both values included [5]
OR
(a) Suppose the content of a text file Notes.txt is:
“The way to get started is to quit talking and begin doing” What will be the output of the following Python code?
F = open (“Notes.txt”)
F.seek(29)
S = F.read()
print(S)
(b) Consider the tables Product and Client with structures as follows:

Product Client
PI_D CI_D
ProductName CName
Manufacturer CCity
Price CProd

Write Python codes for the following to display the Client Name, City from table Client
Answer:
(a) fUN#pYTHONn#

(b) import MySQLdb
db=MySQLdb.connect(‘localhost’ , ‘Admin’, ‘Admin@pwd’, ‘cosmetics’)
cursor=db.cursor()
sql=”””select * from Product where Price BETWEEN %F to %F'”‘”
value = (50,100)
try:
cursor.execute(sql, value)
results = cursor.fetchall()
print ( “ID ProductName Manufacturer Price”)
for row in results:
PID = row[0]
PName = row[1]
PManu = row[2]
PPrice = row[3]
print (” %s %s %s %s”, % (PID, PName, PManu, PPrice))
print (cursor.rowcount, “Records Found”)
except:
print (“Error unable to Fetch data”)
cursor.close()
db.close()

OR

(a) quit talking and begin doing
(b) import MySQLdb
db = MySQLdb.connect(‘localhost’ ,
‘Admin’, ‘Admin@pwd’ , ‘cosmetics’)
cursor=db.cursor()
sql=”””select ClientName, City
From Client”””
try:
cursor.execute(sql)
results = cursor.fetchall()
print (“ClientName”,”City”)
for row in results:
print (“%s %s”, % (row[0], row[1]))
print (cursor.rowcount, “Records Found”)
except:
print (“Error unable to Fetch data”)
cursor.close()
db.close()

Commonly Made Error:
Students do not connect to the database. Sometimes they do not create a cursor object.

Answering Tip:
Connections to database should be established ! ! and cursor object should be created using cursor().

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Question 33.
What happens when we use file open () function in Python ?
Create file phonebook.dat that stores the details in following format:

Name Phone
Jivin 86666000
Kriti 1010101

Obtain the details from the user. [5]
OR
What is closed attribute of a file object? i*fi!
A file phonebook.dat stores the details in the following format:

Name Phone
Jivin 86666000
Kriti 1010101

Write a program to edit the phone numbers of “Arvind” in file. If there is no record for “Arvind” report error.
Answer:
When open () function is used, Python stores the reference of mentioned file in the file_object.

PROGRAM

fp1 = open ("phonebook.dat", 'w1)
fp1.write ("Name")
fp1.write (" ")
fp1.write ("Phone")
fp1.write ('\n')
while True:
name = input ("Enter name:")
phno = input ("Enter phone no:")
fpl.write (name)
fp1.write (" ")
fp1.write (phno)
fp1.write ("\n")
ch = input ("Want to enter more=y/n")
if ch == 'N' or ch == 'n':
break
fp1.close()

OR

closed attribute stores True or False depending on if file is closed or not.

PROGRAM

fpl = open ("phonebook.dat", 1w+1 )
list = " "
while list:
pos = ftell ()
list = fpl.readline ()
name, phone = list.split ()
if name == "Arvind":
phone = input ("Enter new number:")
fp.seek (pos,0)
fp.write (name)
fp.write (" ")
fp.write (phone)
fp.close ()
break
else:
print ("Name\"Arvind\" not found.'')

Section – E

Question 34.
Consider the following tables CABHUB and CUSTOMER and answer (i), (ii) and (iii) parts:
Table: CABHUB
CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions 6
Table: CUSTOMER

Ccode Cname Vcode
1 Hemant Sahu 101
2 Raj Lai 108
3 Feroza Shah 105
4 Ketan Dhal 104

(i) Illustrate Primary and alternate keys in the given table (CABHUB and CUSTOMER).
(ii) Give the output of the following SQL queries:
SELECT COUNT (DISTINCT Make) FROM CABHUB;
(iii) Write SQL commands for the following statements:
(a) To display the names of all the white coloured vehicles.
(b) To display name of vehicle and capacity of vehicles in ascending order of their sitting capacity. [1+1+2=4]
OR
(iii) Write statements to
(a) Delete the records of vehicles of white colour.
(b) Add a column Pnum in the table customer with datatype as num.
Answer:
(i) Primary key of CABHUB = Vcode
Alternate key of CABHUB = VehideName.
Primary key of Customer = Ccode
Alternate Key of CUSTOMER = Cname.

(ii) 4

(iii) (a) SELECT VehideName From CABHUB WHERE Color = “WHITE”;

(b) SELECT VehideName, Capadty FROM CABHUB ORDER BY Capadty ASC;

OR

(iii) (a) DELETE FROMCARHUB WHERE color=”white”

(b) ALTER TABLE customer ADD(PNUM integer);

CBSE Sample Papers for Class 12 Computer Science Set 5 with Solutions

Question 35.
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
(A) AKSHAY.XII,A
(B) ABHISHEK.XII,A
(C) ARVIND.XIEA
(D) RAVLXITA
(E) 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) Write the suitable code for blank space in line marked as Statement-1.
(ii) Write the missing code for blank space in line marked as statement-2.
(iii) Write the function name (with argument) that should be used in the blank space of line marked as Statement-3. [1×1+2=4]
Answer:
(i) csv
(ii) “Student.csv”, “w”
(iii) writer(fh).