Professional Documents
Culture Documents
SESSION: 2021-22
SUBJECT: COMPUTER SCIENCE
MID TERM EXAM
TIME: 2 Hrs MM: 50 Marks
Note:
4. …………loop is the best when the numbers of iterations are not known.
1
i. while ii. do-while iii. For iv. None of these
5. In the nested loop ……………..loop must be terminated before the outer loop.
1
i. Outer ii. enclosing iii. inner iv. None of these
Write a program to implement a Stack for these book –details (book no. , book name). that is , now
each item node of the stack contains two types of information- a book no and its name . just implement
PUSH and pop() operations.
OR
16. 3
Write a program to perform insert and delete operations on a Queue containing
Members’ details as given in the following :
Member no. integer
Member name string
Age integer
Evaluate following postfix expressions while showing status of stack after each
operation given A=3, B=5, C=1, D=4
17. 3
AB*C/D*
18. Write the algorithm to Evaluate of postfix expression. 3
OR
Write a program to count the number of uppercase alphabets present in a text file “
abc.txt”.
21. Define pickling in Python. Explain serialization and deserialization of Python object. 5
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
22. 5
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()
a) Identify the suitable code for blank space in line marked as Statement-1
i) csv file ii) CSV iii) csv iv) Csv
b) Identify the missing code for blank space in line marked as Statement-2?
i) "School.csv","w" ii) "Student.csv","w" iii) "Student.csv","r" iv) "School.csv","r"
c) Choose the function name (with argument) that should be used in the blank space of line marked as
Statement-3
i) reader(fh) ii) reader(MyFile) iii) writer(fh) iv) writer(MyFile)
d) Identify the suitable code for blank space in line marked as Statement-4.
i) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
ii) ROLL_NO, NAME, CLASS, SECTION
iii) 'roll_no','name','Class','section'
iv) roll_no, name, Class, section
e) Choose the function name that should be used in the blank space of line marked as Statement-5 to
create the desired CSV File?
i) dump() ii) load() iii) writerows() iv) writerow()
--------X--------