Class12 CS Quarterly QP
Class12 CS Quarterly QP
Class12 CS Quarterly QP
General Instructions:
1. This question paper contains 7 pages
2. Please check this question paper contains 35 questions.
3. The paper is divided into 4 Sections- A, B, C, D and E.
4. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
5. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
6. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
7. Section D, consists of 3 questions (31 to 33). Each question carries 5 Marks.
8. Section E, consists of 2 questions (34 to 35). Each question carries 4 Marks.
9. All programming questions are to be answered using Python Language only.
SECTION-A 19 * 1 = 19
Select the most appropriate option out of the options given for each question. Attempt ALL 18
questions:
1. Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is incorrect?
a) print(T[1]) b) T[2] = -29 c) print(max(T)) d) print(len(T))
2. Find the invalid identifier from the following:
a. none b. address c. Name d. pass
3. Which of the following operator cannot be used with string data type?
a. + b. in c. * d. /
4. What is the output of the following code:
T=(100)
print(T*2)
a. Syntax error b. (200,) c. 200 d. (100,100)
5. Evaluate the following expression and identify the correct answer.
16 – (4 + 2) * 5 + 2**3 * 4
a. 54 b. 46 c. 18 d. 32
6. Which statement will merge the contents of both dictionaries?
a. dict_exam.update(dict_result) b. dict_exam + dict_result
c. dict_exam.add(dict_result) d. dict_exam.merge(dict_result)
7. In a stack, if a user tries to remove an element from empty stack it is called _________
a) Underflow b) Empty collection
c) Overflow d) Garbage Collection
18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks
like a text file.
Reason (R): The information is organized with one record on each line and each field is
separated by comma.
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
SECTION – B 7 * 2 = 14
19. Differentiate between mutable and immutable objects in Python language with example.
20. Observe the following Python code very carefully and rewrite it after removing all syntactical
errors with each correction underlined.
DEF execmain():
x = input("Enter a number:")
if (abs(x)=x):
print "You entered a positive number"
else:
x=*-1
print "Number made positive:"x
execmain()
21. Write a user defined function findname(name) where name is an argument in Python to
delete phone number from a dictionary phonebook on the basis of the name, where name is
the key.
OR
Write a small python function that receive two numbers and return their sum, product,
difference
and multiplication and modulo division.
22. What is LIFO data structure? Give any two applications of a stack?
23. Consider a binary file emp.dat having records in the form of dictionary. E.g {eno:1,
name:”Rahul”, sal: 5000} write a python function to display the records of above file for those
employees who get salary between 25000 and 30000
24. The file “New.txt” contains the following:
Better than Heaven or Arcadia
I love thee, o my India!
And thy love I shall give
To every brother nation that lives.
and find the output produce by following code fragment?
f=open(“new.txt”,”r”)
n1=0
for line in f:
n1+=1
print (n1)
25. What are the underflow and overflow conditions?
SECTION – C 5 * 3 = 15
26. A file ‘Admission.dat’ has already been created with the records containing admission
number, name and stream of a number of students as sub-lists of list. Define a function
Delete() to open the file in appropriate mode. Delete the record whose admission number is
input from keyboard.
27. The following figure shows a stack:
T 4
R 3
F 2
Q 1
N 0
def output(m=5):
for i in range(0,m):
print(div5(i),’@’,end=” “)
print(”)
output(7)
output()
output(3)
30. What are the possible outcome(s) expected from the following python code? Also specify
maximum and minimum value, which we can have.
def main():
p = ‘MY PROGRAM’
i=0
while p[i] != ‘R’:
l = random.randint(0,3) + 5
print p[l],’-’,
i += 1
(i) R – P – O – R –
(ii) P – O – R – Y –
(iii) O -R – A – G –
(iv) A- G – R – M –
SECTION – D 2*4=8
Both the questions are compulsory.
31. A binary file “student.dat” has structure [rollno, name, marks].
i. Write a user defined function insertRec() to input data for a student and add to student.dat.
ii. Write a function searchRollNo( r ) in Python which accepts the student’s rollno as
parameter and searches the record in the file “student.dat” and shows the details of student
i.e. rollno, name and marks (if found) otherwise shows the message as ‘No record found’.
32. The functions to perform PUSH and POP operations on a stack are defines below:
def push(st,top, n):
top = top +___ # line 1
________ # line 2
def pop(st, top):
if (top == -1):
print (“Underflow”)
else:
# line 3
top = _______ - 1 # line 4
In the above functions, some places are left blank to be filled with values/ functions.
Answer the following questions:
a. What value/ function will be filled in the blank of Line 1?
top = top +___
b. What value/ function will be filled in the blank of Line 2?
c. What value/ function will be filled in the blank of Line 3?
d. What value/ function will be filled in the blank of Line 41?
top = _____ - 1
OR
Predict the output with respect to the list L=[40,20,30,10,50]
(a) print(len(L))
(b) L.pop() ; print(L)
(c) L.append(70); print(L)
(d) L.sort(); print(L)
SECTION – E 3 * 5 = 15
33. Write a program in Python that defines and calls the following user-defined functions:
1. COURIER_ ADD(): It takes the values from the user and adds the details to a csv
file ‘courier.csv’. Each record consists of a list with field elements as a cid, s_name, Source
and destination to store Courier ID, Sender name, Source and destination address
respectively.
2. COURIER_SEARCH (): Takes the destination as the input and displays all the courier
records going to that destination.
34. Vedika has created a dictionary containing names and marks as key-value pairs of 5 students.
Write a program, with separate user-defined functions to perform the following operations:
1. Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
2. Pop and display the content of the stack.
The dictionary should be as follows:
d={“Ramesh”:58, “Umesh”:78, “Vishal”:90, “Khushi”:60, “Ishika”:95}
Then the output will be: Umesh Vishal Ishika
35. (a) Define Exception?
(b) Compare the following two Python codes shown below and state the output if the
input entered in each case is -6?
CODE 1
import math
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))
CODE 2
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))